Function by_ref(&$_value)
{
return echo “value is passed by reference: $_value”;
}
Function by_either($_value)
{
return echo “value maybe passed by reference: $_value”;
}
$var = “test”;
by_ref($var); // Must use variable
by_either(&$var); // Variable passed by reference
by_either(“test”); // Value just passed
Is there a way to make function ‘by_either’ tell if the value passed to it was made by reference versus by value?
The reason I’m asking is because I have a class were you can pass it an associative array that may contain lots of key/value pairs. I don’t want to declare/force it to be passed by reference, yet I would like to unset() the array in my constructor (after I’m done using it) if I knew it was passed by value.