note 77328 deleted from language.variables.scope by danbrown

From: Date: Mon, 17 Oct 2011 16:23:08 +0000
Subject: note 77328 deleted from language.variables.scope by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183930@lists.php.net to get a copy of this message
Note Submitter: crack wilding ---- Another way of dealing with a large number of globals is to declare a single global array and then put all your global variables into it. Like this: <?php $_G = array( 'foo' => 'some text', 'bar' => 4, 'boo' => 'more text, 'far' => 'yet more text' ); ?> Now you just declare the one global array in each function: <?php function blah() { global $_G; echo $_G['foo']; // or whatever } ?> You can freely add to it without having to go back and add variable declarations to your functions. Kinda like using the $GLOBALS superglobal, except you don't have to type so much.

« previous php.notes (#183930) next »