|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18516 Variable-variables referencing a superglobal in a function don't work
Submitted: 2002-07-23 19:14 UTC Modified: 2002-07-23 21:17 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dilbert at hack3r dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.2.2 OS: All
Private report: No CVE-ID: None
 [2002-07-23 19:14 UTC] dilbert at hack3r dot com
<? $h= "_GET";
   echo "<hr>";
   function g() { print_r($_GET); }
   echo "<hr>";
   function t() { $g= "_GET"; print_r($$g); }
   echo "<hr>";
   $h = "hi";
   function b() { global $h; $g = "h"; print_r($$g); }

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



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-04 19:56 UTC] mr dot nobody at nowhereville dot com
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...


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


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
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 08:01:29 2023 UTC