note 81033 added to language.variables.variable
| From: | NathanHammond at osu1 dot php dot net | Date: | Mon, 11 Feb 2008 23:41:12 +0000 |
| Subject: | note 81033 added to language.variables.variable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136054@lists.php.net to get a copy of this message | ||
These are the scenarios that you may run into trying to reference superglobals dynamically. Whether
or not it works appears to be dependent upon the current scope.
<?php
$_POST['asdf'] = 'something';
function test() {
// NULL -- not what initially expected
$string = '_POST';
var_dump(${$string});
// Works as expected
var_dump(${'_POST'});
// Works as expected
global ${$string};
var_dump(${$string});
}
// Works as expected
$string = '_POST';
var_dump(${$string});
test();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 74.172.164.202
----
Manual Page -- http://www.php.net/manual/en/language.variables.variable.php
Edit -- https://master.php.net/note/edit/81033
Del: integrated -- https://master.php.net/note/delete/81033/integrated
Del: useless -- https://master.php.net/note/delete/81033/useless
Del: bad code -- https://master.php.net/note/delete/81033/bad+code
Del: spam -- https://master.php.net/note/delete/81033/spam
Del: non-english -- https://master.php.net/note/delete/81033/non-english
Del: in docs -- https://master.php.net/note/delete/81033/in+docs
Del: other reasons-- https://master.php.net/note/delete/81033
Reject -- https://master.php.net/note/reject/81033
Search -- https://master.php.net/manage/user-notes.php