note 25261 rejected from language.variables.scope by nicos
| From: | nicos@php.net | Date: | Tue, 17 Sep 2002 13:56:49 +0000 |
| Subject: | note 25261 rejected from language.variables.scope by nicos | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-36836@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!"