Posted by Oli Filth on 09/16/05 15:19
am_ggh@hotmail.com said the following on 15/09/2005 17:48:
> Erwin
>
> Thanks for replying. I appreciate your input.
>
> Yes you are right, I have the need to set a value to the variable in
> the calling environment (my case happens to be a function within a
> function), In fact I need to possibly initialize variables (since they
> might not even exist) in the calling function. $GLOBALS etc. lead to
> unwanted side effects because of the nature of the task at hand*.
>
Would passing a variable by reference do what you want?
e.g.
function foo()
{
$a = 5;
bar($a);
// now $a == 8
}
function bar(&$var)
{
// $var is a reference to $a in the callee...
$var = 8;
}
--
Oli
[Back to original message]
|