Bug #15810: superglobals does not work with dynamic vars in functions

From: Date: Fri, 01 Mar 2002 14:51:28 +0000
Subject: Bug #15810: superglobals does not work with dynamic vars in functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-1403@lists.php.net to get a copy of this message
From: goba@php.net Operating system: win2k PHP version: 4.1.0 PHP Bug Type: Scripting Engine problem Bug description: superglobals does not work with dynamic vars in functions See the attached example. The first print_r() in the function does not print out anything, while the second prints out the contents of $_GET. I have set $_GET to a dummy array to let you test without a server. Conclusion: dynamic names does not work for superglobals in functions (I have also tested them in methods, but these handled the same as functions...). Though dynamic names work in global scope for superglobals... <?php $_GET = array("aa"); $method = "_GET"; $var = $$method; echo "\n$method vars in global scope:\n"; print_r($var); // prints out the array function test () { $method = "_GET"; $var = $$method; echo "\n$method vars in test func:\n"; print_r($var); // prints out nothing echo "\n_GET vars in test func:\n"; $var = $_GET; print_r($var); // prints out the array } test(); ?> -- Edit bug report at http://bugs.php.net/?id=15810&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=15810&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=15810&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=15810&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=15810&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=15810&r=support Expected behavior: http://bugs.php.net/fix.php?id=15810&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=15810&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=15810&r=submittedtwice

« previous php.bugs (#1403) next »