Bug #18516: Variable-variables referencing a superglobal in a function don't work
| From: | dilbert at hack3r dot com | Date: | Tue, 23 Jul 2002 23:14:43 +0000 |
| Subject: | Bug #18516: Variable-variables referencing a superglobal in a function don't work | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-14959@lists.php.net to get a copy of this message | ||
From: dilbert@hack3r.com
Operating system: All
PHP version: 4.2.2
PHP Bug Type: Variables related
Bug description: Variable-variables referencing a superglobal in a function don't work
<? $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 bug report at http://bugs.php.net/?id=18516&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18516&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18516&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18516&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18516&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18516&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18516&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18516&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18516&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18516&r=globals