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

> I have programed a function for counting Date:
> 
> function Datereturn()
>   {
<snip>
>   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 
<http://www.php.net/manual/en/function.return.php>.  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);
}

$returned=myFunc();
echo "{$returned[0]}, {$returned[1]}, {$returned[2]}";

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to