In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Simonk) wrote:

> I have programed a function for counting Date:
> function Datereturn()
>   {
>   Return $realday;
>   Return $month;
>   Return $year;
>            }
> But when I want to echo out the result, I have typed:
> Datereturn();
> echo "$year, $month, $realday";
> Then the server return:
> Undefined variable year, month, realday

Re-read the docs on the "return" statement 
<>.  A few pointers:

A) As soon as a 'return' is encountered, function execution ends; it will 
never get to the lines containing additional returns.

B) To return multiple values in a single 'return' statement, return an 
array variable.

C) 'Return' does not set variables in the global scope for you; it's up to 
you to explicity set a variable.

function myFunc()
return array ($one, $two, $three);

echo "{$returned[0]}, {$returned[1]}, {$returned[2]}";


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to