Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14452 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42586 invoked by uid 1010); 28 Jan 2005 23:53:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42570 invoked by uid 1007); 28 Jan 2005 23:53:45 -0000 Message-ID: <20050128235345.42569.qmail@lists.php.net> To: internals@lists.php.net Date: Sat, 29 Jan 2005 00:53:44 +0100 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 References: <20050128223155.81436.qmail@lists.php.net> <5.1.0.14.2.20050128145327.04025190@localhost> <20050128233054.9657.qmail@lists.php.net> <20050128234649.27693.qmail@lists.php.net> In-Reply-To: <20050128234649.27693.qmail@lists.php.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 217.86.69.74 Subject: Re: [PHP-DEV] Using Superglobals for variable variables works From: michael.virnstein@brodos.de (Michael Virnstein) yep, figured it out already. Problem is the german version of the manual. It is wrong and doesn't say anything about functions and methods. It simply says you can't use superglobals for variable variable and uses a illogical example ${$_GET}, whatever that should mean ;). The english manual is right though and says you can't use it in functions and methods. Thanks anyway, Michael Sara Golemon wrote: >>but this does also work, atm. i'm using PHP 5.0.2 on Windows XP with >>apache 1.3 and if i call my php page with >>http://localhost/test.php?test=works it works. >> >>//test.php >>>$a = '_GET'; >>echo ${$a}['test']; >>var_dump($$a); >>?> >> > It works when you're already at the global scope, but try this: > > function foo() { > var_dump($_GET); > $g = '_GET'; > var_dump($$g); > } > > foo(); > ?> > > The first var_dump() will work right because $_GET is a superglobal and ZE > picks it out of the global context correctly, the second var_dump() will > yield a NULL and an undefined index since it will try to access it from the > local symbol table and not find it. > > Declaring a variable as superglobals is just a hint to the scripting engine > to retreive it from the global symbol table rather than the active symbol > table (Superglobals, by definition live in the global symbol table). > > Your example worked because at the time the variable variable was resolved, > the global symbol table WAS the active symbol table. > > -Sara