note 35822 added to language.variables.variable
| From: | frank at vista dot com | Date: | Tue, 16 Sep 2003 03:02:34 +0000 |
| Subject: | note 35822 added to language.variables.variable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56552@lists.php.net to get a copy of this message | ||
Variable variables let you assign values to invalid variable names (those with hyphens, dots, etc.).
$foo = "invalid-variable";
$$foo = "value of invalid variable";
How do you access them once you've done this?
echo ${"invalid-variable"}; // value of invalid variable
Note that this works with registered globals (i.e.
script.php?invalid-variable=value+of+invalid+variable) although dots are converted to underscores
for query parameter names.
Basically, any valid or invalid variable name can be used, as long as it's in quotes and
braces:
$foo = '4site';
$$foo = 'not yet';
echo ${'4site'} // not yet
----
Manual Page -- http://www.php.net/manual/en/language.variables.variable.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35822
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35822&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35822&report=yes