note 25261 added to language.variables.scope
| From: | mikael dot lenell at technordic dot com | Date: | Tue, 17 Sep 2002 13:35:07 +0000 |
| Subject: | note 25261 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36834@lists.php.net to get a copy of this message | ||
Since you can create global variables from within functions, I used that feature to create singleton
classes that keeps track of all objects so they can all contain the same values.
It would have been good to know about static variables effect on class methods (the fact that they
are the same between instances).
An example of creating a global from within a function for the interested:
function MakeGlobal()
{
$GLOBALS[ 'SayIt' ] = "I'm black and I'm proud!";
}
print $SayIt; // Prints "I'm black and I'm proud!"
--
http://www.php.net/manual/en/language.variables.scope.php
http://master.php.net/manage/user-notes.php?action=edit+25261
http://master.php.net/manage/user-notes.php?action=delete+25261
http://master.php.net/manage/user-notes.php?action=reject+25261