I'm having huge trouble doing something which ought to be extremely simple: returning a variable from a function. I can't see what I'm doing wrong, and starting to suspect that there's some kind of php.ini option that might be configured the wrong way - any help greatly appreciated.
I define the following function in a function library (cons_fns.php):
function double_me($input_me)
{
$output_me = ($input_me * 2);
echo ("<p>input: $input_me<br>" .
"output: $output_me</p>");
return $output_me;
}
I then call this function from a script as follows:
// include the file library
include("../cons_fns.php");
double_me(4);
echo("<p>and the function returns: $output_me</p>");
Obviously in the above example I would expect to have $output_me returned to the script with a value equal to 8. However, when I run the script I get the following HTML:
input: 4
output: 8
and the function returns:
So although the function is working (as shown by the "input: 4 output: 8"), it looks like the $output_me variable is then not being passed back to the script. This ought to be fairly basic but I have no idea what's wrong. What am I missing here? Thanks in advance for any help - saxnet