Hi!
If you don't like the approach DLB suggested, you may want to consider returning values from a function 'by reference'. At least, this is the option used in C, VB, Delphi, etc, etc.
If you don't know what references are (don't confuse with C pointers), it's an internally-maintained address of a variable. If a variable is passed by reference and you set it to a value, PHP looks up the reference to variable, resolves it and sets the resolved variable to appropriate value.
Actually, global does the same thing - it creates a private variable which contains the address of the variable whose name you specified.
For instance, in this function that check the equality of two variables (rather stupid, I should say), we output additional values:
function check_equal($input1, $input2, &$output1, &$output2)
{
$output1 = "Input variable 1 is ".$input1;
$output2 = "Input variable 2 is ".$input2;
return ($intput - $input2 > 0);
}
This way variables are correctly returned to the calling environment.
PHP is a great language because it allows to return values of different types, but many modern languages don't support it and are type-safe (so the function should only be declared to return a value of one type). For this reason returning by reference is quite a common practice in these languages.
You should note that PHP passes variables into functions by value by default (just like in C).
Hope this has helped.
Best,
Stas