Bug #16687 Updated: Constants not being interpreted in "variable variables"
| From: | goba@php.net | Date: | Fri, 19 Apr 2002 19:17:42 +0000 |
| Subject: | Bug #16687 Updated: Constants not being interpreted in "variable variables" | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-5425@lists.php.net to get a copy of this message | ||
ID: 16687
Updated by: goba@php.net
Reported By: lux@simian.ca
Status: Open
Bug Type: Documentation problem
Operating System: Red Hat Linux 7.1
PHP Version: 4.2.0
New Comment:
I have already reported this problem, but nothing happened.
Superglobals seemed to be accessible with variable variables in the
global scope, but not in any local scope (inside a function). Derick
told me, that it is by design, but IMHO this is incosistent, and quite
ugly :((
--
Goba
Previous Comments:
------------------------------------------------------------------------
[2002-04-19 14:53:51] mfischer@php.net
Reclassified.
It should be documented that due the special way super globals are
treated the cannot be used with variable variables.
------------------------------------------------------------------------
[2002-04-19 12:40:50] mfischer@php.net
True true. Derick (or someone else) mind briefly explaining why this
is/has to be different?
------------------------------------------------------------------------
[2002-04-19 11:11:00] lux@simian.ca
But then why does it work under certain circumstances and not others?
Regardless whether intended or not, this is inconsistent behaviour.
I also think that having these differences between regular variables
and the "superglobals" shouldn't be necessary. If I can't use them in
the same contexts as regular variables, then I would personally prefer
the $HTTP_*_VARS instead, because you can.
I have found my approach to abstracting this difference ($HTTP_*_VARS
vs. $_*) between PHP versions to be really beneficial to my scripts. I
can abstract them both down to one name, and use a single reference to
the appropriate one instead of sticking if statements every time I need
to know which one to use.
Sorry to keep buggin' ya, but I think this may be a fair enough
argument for change.
------------------------------------------------------------------------
[2002-04-19 10:33:59] derick@php.net
You can't use superglobals indirectly, check this:
$t = "_GET";
var_dump ($$t);
doesn't work neither, and it wasn't supposed to work.
However, this does work (because $HTTP_GET_VARS is not a superglobal):
$t = "HTTP_GET_VARS";
var_dump ($$t);
Derick
------------------------------------------------------------------------
[2002-04-18 19:09:09] sniper@php.net
reclassified
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/16687
--
Edit this bug report at http://bugs.php.net/?id=16687&edit=1