note 30484 added to language.variables.predefined
| From: | Good at rack1 dot php dot net | Date: | Wed, 19 Mar 2003 15:18:09 +0000 |
| Subject: | note 30484 added to language.variables.predefined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45524@lists.php.net to get a copy of this message | ||
Warning:
If you use dynamic variables in a local scope, the variable doesn't "know" when it
should be a superglobal. An example will help elucidate this:
function Example($Variable_Name='_POST') {
print_r($$Variable_Name);
} // End Example
This would print out
NULL
To use a dynamic variable to reference a superglobal, you have to declare the value (not the name)
as a global:
function WorkingExample($Variable_Name='_POST') {
global $$Variable_Name;
print_r($$Variable_Name);
} // End WorkingExample()
This would print out the contents of your $_POST variable.
This threw me when I first tried it, but it makes sense, in a way.
--
http://www.php.net/manual/en/language.variables.predefined.php
http://master.php.net/manage/user-notes.php?action=edit+30484
http://master.php.net/manage/user-notes.php?action=delete+30484
http://master.php.net/manage/user-notes.php?action=reject+30484