I created a function that is intended to set some variables in the scope of the calling
process. For example:
function my_func($label)
{
...
$GLOBALS[$label] = 10;
}
my_func("var1");
print ($var1); // Work ok!
The problem I have is that if I invoke the function from within another
function, the variable is not available in its scope, but only in global scope:
function caller_func(...)
{
...
my_func("var1");
print $var1; // Error, variable not defined in the scope of this function
}
Is there any way to indicate to the parser to create a variable in the scope of
the caller, instead of global scope? Of course I could do a global $var1
inside the function, but this would not be the prefered solution.
Thanks,
Jaime