Hello all, I'm new to PHP scripting and I have a pretty basic question about returning a variable from within a user defined funciton. My question is: How do I do it? I've read through the PHP manual about returning values, but I can't seem to figure it out. As I said, I'm not a very knowledgable programmer, so I can't figure this out. Here is a basic script I've written with a funciton.
><script language="php">
// declare the function
function test_function($var_01, $var_02) {
$var_03 = $var_01 + $var_02;
echo "$var_01 + $var_02 = $var_03 <br>";
return $var_03;
}
// declare starting variables
$var_01=5;
$var_02=6;
// run the function
test_function($var_01, $var_02); // this will output: 5 + 6 = 11
// output variable values
echo "var_01 is: $var_01 <br>";
echo "var_02 is: $var_02 <br>";
echo "var_03 is: $var_03 <br>"; // this does not get output
// Why is this variable not returned from the function?
</script>
How do I run the function and then have it return the value of $var_03?
$var_03 is a valid variable from within the funciton, as it's value is output as 11.
What am I doing wrong?
Thanks, and please go easy on me