Re: [PHP4BETA] Global variables inside a function?

From: Date: Wed, 05 Apr 2000 19:18:25 +0000
Subject: Re: [PHP4BETA] Global variables inside a function?
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-13178@lists.php.net to get a copy of this message
Lars Torben Wilson wrote: > > Peter Kovacs writes: > > Is there an easy and efficient way to declare all the global variables to > > be global within a function? > > > > Peter > > > > -------------------------------------------------- > > Peter D. Kovacs KnowPost.com LLC > > Lead Engineer peter@knowpost.com > > -------------------------------------------------- > > In PHP4, this is simple: just put 'extract( $GLOBALS );' at the > beginning of the function definition: Unfortunately, this only gives you read, not write, access to the GLOBALS, and it's also not especially efficient. What would be nice is a way to modify the scoping rules to be more C/C++/etc.-like, maybe w/ a func like: set_var_scope("LOCAL_ONLY") // the default and set_var_scope("LOCAL_GLOBAL") Ciao, Andreas

« previous php.version4 (#13178) next »