note 60151 added to language.variables
| From: | warhogatwarhogdotnet at osu1 dot php dot net | Date: | Wed, 28 Dec 2005 07:11:11 +0000 |
| Subject: | note 60151 added to language.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100831@lists.php.net to get a copy of this message | ||
> 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.
----
Manual Page -- http://www.php.net/manual/en/language.variables.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60151
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60151&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60151&report=yes
Search -- http://master.php.net/manage/user-notes.php