Re: help with PHP global array

From: Date: Thu, 07 Feb 2002 17:43:08 +0000
Subject: Re: help with PHP global array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-83883@lists.php.net to get a copy of this message
> All variables in PHP are local to the scope in which it is defined. You > cannot declare a variable as global (as such). To use a global variable: This is true. But I believe that the original question was actually the other way around... Make a local variable into a global one. The way to do that is this: <? myFunc() { $myFuncLocalVar = "Hello!"; echo $myFuncLocalVar; $GLOBALS[myFuncLocalVar] = $myFuncLocalVar; } myFunc(); echo $myFuncLocalVar; ?> Chris

« previous php.general (#83883) next »