note 51778 added to language.variables
| From: | pilotdoofy at gmail dot com | Date: | Mon, 11 Apr 2005 02:28:20 +0000 |
| Subject: | note 51778 added to language.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87805@lists.php.net to get a copy of this message | ||
Note that with php you can also use double variables. I don't believe this was stated yet. Here
is how you would go about doing so. They are handy for OOP (Object Oriented Programming) and make it
easier to recall what the variables are used for and what their contents are.
<?php
# declaring double and single variables
$my_variable = 'PHP is neat';
$$my_variable = ' and handy!';
echo $my_variable . $$my_variable;
# this would return 'PHP is neat and handy!'
?>
The use of double variables becomes more adament when you begin creating large projects. Say for
instance someone has a variabled named $message_title for an online webmail system. Well, they could
have the variable $$message_title which could be formatted in some way and they only want to return
the formatted string.
----
Manual Page -- http://www.php.net/manual/en/language.variables.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51778
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51778&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51778&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51778&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51778&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51778&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51778&report=yes
Search -- http://master.php.net/manage/user-notes.php