Re: Variable Variables and Superglobals

From: Date: Fri, 06 Aug 2004 03:03:47 +0000
Subject: Re: Variable Variables and Superglobals
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-11953@lists.php.net to get a copy of this message
* Thus wrote A.Rico: > What the PHP documentation says about variable variables and > superglobals is that you can't use them as a "pointer": > > /*Warning*/ > > / Please note that variable variables cannot be used with PHP's > Superglobal arrays > > <http://www.php.net/manual/en/language.variables.predefined.php#language.variables.superglobals>. > This means you cannot do things like ${$_GET}. If you are looking > for a way to handle availability of superglobals and the old > HTTP_*_VARS, you might want to try referencing > <http://www.php.net/manual/en/language.references.php> > them. / > > what I intended was to use a "normal" globally defined variable to > "point" to a superglobal; that, in fact, works in the global scope, but > not in the function scope: > > // Code ////////////////////////////////////////////////////////////// > $varvar="_ENV"; > > echo $_ENV["OS"]; // --> Windows NT > echo ${$varvar}; // --> Windows NT This is a documentation issue, i believe, as noted on: http://php.net/variables.predefined Variable variables super globals aren't allowed inside functions or methods. The waring on the page you reference is fixed in the docs reflecting this. Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid!

« previous php.internals (#11953) next »