RE: [PHP] pass globals to functions???

From: Date: Thu, 24 Oct 2002 20:16:56 +0000
Subject: RE: [PHP] pass globals to functions???
Groups: php.general 
Request: Send a blank email to php-general+get-121350@lists.php.net to get a copy of this message
<? // this is main $foo = 'bar'; test(); test2(); function test() { global $foo; echo "foo is $foo<br>"; } function test2() { echo "foo is {$GLOBALS['foo']}<br>"; } ?> Kirk > Some have eluded to this but I haven't seen a working > example. I would like > to declare globals in my main script and then inside > functions that need > these globals just somehow use the $GLOBALS or something to > declare the > variables global in the function.

« previous php.general (#121350) next »