#18516 [Com]: Variable-variables referencing a superglobal in a function don't work

From: Date: Sun, 04 Aug 2002 23:56:10 +0000
Subject: #18516 [Com]: Variable-variables referencing a superglobal in a function don't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15984@lists.php.net to get a copy of this message
ID: 18516 Comment by: mr.nobody@nowhereville.com Reported By: dilbert@hack3r.com Status: Bogus Bug Type: Variables related Operating System: All PHP Version: 4.2.2 New Comment: I can't get the $_GET or any version there of to give me anything... If I pass(http://localhost/index.php?P=1&T=2) I expect to get them like... $P=$_GET['P']; I have tried several way to get them but nothing is ever displayed.. Here are ways I have tried to display.. $var_http_get = 'HTTP_GET_VARS'; $local_http_get = $$var_http_get; print $local_http_get['P'] . '*<BR>'; echo "<br><hr>"; $h = "_GET"; foreach($$h as $Value) { print $Value; } echo "<br><hr>"; foreach($_GET as $Value) { print "GET=" . $Value . "<BR>"; } echo "<br><hr>"; All pull nothing.. If I run on $_SERVER I get this SERVER (REQUEST_METHOD) - GET SERVER (SCRIPT_NAME) - /INDEX.PHP SERVER (REQUEST_URI) - /INDEX.PHP?P=3&ID=413 SERVER (REQUEST_LINE) - GET /INDEX.PHP?P=3&ID=413 HTTP/1.1 So I see the data is being passed into but I can not get to it. Windows XP(Home), Viking 1.8 Webserver, PHP 4.2.2 Previous Comments: ------------------------------------------------------------------------ [2002-07-23 21:17:50] sniper@php.net RTFM: http://www.php.net/manual/en/language.variables.variable.php ------------------------------------------------------------------------ [2002-07-23 19:14:42] dilbert@hack3r.com <? $h= "_GET"; print_r($$h); echo "<hr>"; function g() { print_r($_GET); } g(); echo "<hr>"; function t() { $g= "_GET"; print_r($$g); } t(); echo "<hr>"; $h = "hi"; function b() { global $h; $g = "h"; print_r($$g); } b(); ?> I've reported a similiar bug earlier (but forgot to include something trivial in the test script and thought it was a larger one than it is... i was rebuffed, it was marked bogus, and nobody seems to pay attention to "bogus" bugs) In the function above: The first print_r works as expected, verifying that variable-variable referencing DOES work. The g() function works as expected, verifying that superglobals are available in function scope. The t() function seems to do NOTHING, this is where the bug seems to be. The b() function works as expected, verifying that it works with regular globals. -- This has been tested and observed on OpenBSD and linux, with PHP versions 4.2.1 and 4.2.2 Ted ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18516&edit=1

« previous php.bugs (#15984) next »