Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14450 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27717 invoked by uid 1010); 28 Jan 2005 23:46:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27694 invoked by uid 1007); 28 Jan 2005 23:46:49 -0000 Message-ID: <20050128234649.27693.qmail@lists.php.net> To: internals@lists.php.net References: <20050128223155.81436.qmail@lists.php.net> <5.1.0.14.2.20050128145327.04025190@localhost> <20050128233054.9657.qmail@lists.php.net> Date: Fri, 28 Jan 2005 15:46:48 -0800 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Posted-By: 169.229.135.175 Subject: Re: [PHP-DEV] Using Superglobals for variable variables works From: pollita@php.net ("Sara Golemon") > 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: 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