RE: [PHP] Variables inside a function
| From: | Jay Blanchard | Date: | Mon, 08 Mar 2004 18:10:26 +0000 |
| Subject: | RE: [PHP] Variables inside a function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179808@lists.php.net to get a copy of this message | ||
[snip]
I then echo $blah; somewhere else in the script but nothing is echo'd.
How
do I make it so that I can use $blah anywhere in the script?
[/snip]
I went back and re-read the post, and his question above is the
important one....
First you must return something from the function, then you must assign
the returned data to a variable...
long-hand
function blah ($bl,$ah) {
$bl++;
$ah++;
$blah=$bl+$ah;
return $blah;
}
$dork = blah($foo, $bar);
$dork is now the value of the returned $blah and $dork may be used with
the value over and over until it is re-written or over-written