note 60151 deleted from language.variables by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 16:01:13 +0000 |
| Subject: | note 60151 deleted from language.variables by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142149@lists.php.net to get a copy of this message | ||
Note Submitter: warhog at warhog dot net
----
> Variable names follow the same rules as other labels in PHP. A valid variable name starts with
> a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular
> expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
..is not quite true. You can, in fact, only declare variables having a name like this if you use the
syntax <?php $varname = "naks naks"; ?>.. but in fact a variable can have moreless
any name that is a string... e.g. if you look at an array you can have
<?php
$arr[''];
$arr['8'];
$arr['-my-element-is-so-pretty-useless-'];
?>
.. by accessing the variables-namespace via {} you can have the same functinalities for all
variables, e.g.
<?php ${''} = "my empty variable"; ?>
is a valid expression and the variable having the empty string as name will have the value "my
empty variable".
read the chapter on "variable variables" for further information.