#32585 [Opn->Bgs]: Superglobals behave differently inside functions
| From: | johannes@php.net | Date: | Tue, 05 Apr 2005 09:52:37 +0000 |
| Subject: | #32585 [Opn->Bgs]: Superglobals behave differently inside functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76374@lists.php.net to get a copy of this message | ||
ID: 32585
Updated by: johannes@php.net
Reported By: c dot i dot morris at durham dot ac dot uk
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.3.10
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
That's the way it works...
Previous Comments:
------------------------------------------------------------------------
[2005-04-05 11:47:20] c dot i dot morris at durham dot ac dot uk
Description:
------------
When constructing a variable name using the $$foo syntax, it is only
possible to reference a superglobal in this way from outside a
function. Inside a function it appears to reference a variable with the
same name that is local to the function.
In other words, the code
$foo='_REQUEST';
print (${$foo}['bar']);
behaves differently within a function and within the main loop.
I've been able to reproduce this bug on several servers with different
configurations. 4.3.10 is the latest version I have available to test.
Reproduce code:
---------------
Demonstration
http://www.dur.ac.uk/c.i.morris/superglobals.php?foo=123
Source code
http://www.dur.ac.uk/c.i.morris/superglobals.phps
[Note: this server is running an older version of PHP, but the same
effect happens on a non-public server running 4.3.10]
Expected result:
----------------
Out of the function:123
In the function:123
Actual result:
--------------
Out of the function:123
In the function:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32585&edit=1