#22518 [NEW]: Accessing superglobal arrays in functions via variable variable names

From: Date: Mon, 03 Mar 2003 14:06:46 +0000
Subject: #22518 [NEW]: Accessing superglobal arrays in functions via variable variable names
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-34667@lists.php.net to get a copy of this message
From: rabus at users dot sourceforge dot net Operating system: Windows NT PHP version: 5CVS-2003-03-03 (dev) PHP Bug Type: Scripting Engine problem Bug description: Accessing superglobal arrays in functions via variable variable names Please try the following script: <?php function foo() { echo $_SERVER; } foo(); ?> This script returns "Array". This is the expected behavior. Now, try this one: <?php function foo() { $bar = '_SERVER'; echo $$bar; } foo(); ?> This time, an error is returned: Notice: Undefined variable: _SERVER on line 4 This is nonsense, of course: As we see in the example above, the variable should be defined! -- Edit bug report at http://bugs.php.net/?id=22518&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22518&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22518&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22518&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22518&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22518&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22518&r=support Expected behavior: http://bugs.php.net/fix.php?id=22518&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22518&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22518&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22518&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22518&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22518&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22518&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22518&r=gnused

« previous php.bugs (#34667) next »