note 35822 rejected from language.variables.variable by didou
| From: | didou@php.net | Date: | Wed, 14 Jan 2004 12:25:49 +0000 |
| Subject: | note 35822 rejected from language.variables.variable by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-63525@lists.php.net to get a copy of this message | ||
Note Submitter: frank@vista.com
----
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