#24598 [Opn->Bgs]: $$var doesn't work with $var="GLOBALS";
| From: | sniper@php.net | Date: | Fri, 11 Jul 2003 00:27:19 +0000 |
| Subject: | #24598 [Opn->Bgs]: $$var doesn't work with $var="GLOBALS"; | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-43705@lists.php.net to get a copy of this message | ||
ID: 24598
Updated by: sniper@php.net
Reported By: copraonu at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: Win32
PHP Version: 4.3.2
New Comment:
RTFM: http://www.php.net/variables.variable
(you can't use variable variables with superglobals..)
Previous Comments:
------------------------------------------------------------------------
[2003-07-10 18:29:47] copraonu at hotmail dot com
Description:
------------
I needed to get a variable's or array's value when i had it's name
stored in another variable. To get it, i used $$var_name; it all
functioned as expected until it came across with $GLOBALS
Reproduce code:
---------------
//doesn't work, gets nothing:
$var = "GLOBALS";
$var = $$var;
print_r($var);
//does work: prints $GLOBALS
gettype($GLOBALS);
$var = "GLOBALS";
$var = $$var;
print_r($var);
Expected result:
----------------
i expected output exactly like print_r($GLOBALS)'s
Actual result:
--------------
but got nothing.
I managed to get wanted result when i added
gettype($GLOBALS);
before the code;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24598&edit=1