Re: [PHP4BETA] Global Variable scope within functions

From: Date: Wed, 10 May 2000 15:41:12 +0000
Subject: Re: [PHP4BETA] Global Variable scope within functions
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-14757@lists.php.net to get a copy of this message
Chris Adams wrote: > > On 05/09/00 09:43:35 PM psg@cooldog.com wrote: > > >To the PHP4 developer gurus: > > > >Is there any undocumented feature that would make it possible to have a > >function with ALL global variables in its scope? > > > >The equivalent to this: > > > >function foo { > > for (reset($GLOBALS); $Gvn = key($GLOBALS); next($GLOBALS)) > > global $$Gvn; > > .... > >} > > Try extract($GLOBALS). > > However, I would caution that this is usually a sign of a design that needs > reworking. I have to politely disagree. HTTP is stateless, after all, and interpreted (so that your entire PHP tree is not involved in every use). If you follow "true" clean programming you shouldn't have any global variables at all -- try that with PHP :-P. Ciao, Andreas

« previous php.version4 (#14757) next »