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

From: Date: Fri, 01 Mar 2002 14:55:31 +0000
Subject: Bug #15810 Updated: superglobals does not work with dynamic vars in functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-1404@lists.php.net to get a copy of this message
ID: 15810 Updated by: derick@php.net Reported By: goba@php.net Status: Open -Bug Type: Scripting Engine problem +Bug Type: Feature/Change Request Operating System: win2k PHP Version: 4.1.0 New Comment: It was not supposed to work, so I'm making this a feature request. If you want I can dig up some old mail / chat logs about this... Derick Previous Comments: ------------------------------------------------------------------------ [2002-03-01 09:51:27] goba@php.net 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 this bug report at http://bugs.php.net/?id=15810&edit=1

« previous php.bugs (#1404) next »