On Thu, 18 Jul 2002 08:40:08 -0600, you wrote:

See below...

>At 09:20 PM 7/17/02 -0500, Michael Sims wrote:
>
>>$superglobals = array("var1", "var2", "var3", "var4", "var5", "...");
>>
>>Now inside the function you can do this:
>>
>>function somefunction ($somevar) {
>>
>>   global $superglobals;
>>   foreach($superglobals as $varname) {
>>     global $$varname; //resolves to $var1, $var2, $var3, etc.
>>   }
>>
>>   //Other stuff here
>>
>>}
>
>You're working too hard!
>
>function somefunction( $somevar ) {
>
>global $suberglobals;
>
>extract( $superglobals );
>
>//Other stuff here
>
>}

Sorry, but your version is not functionally equivalent to mine.  The
call to extract() is creating locally scoped versions of those
variables which do NOT reference the global versions.  For proof, go
here:

http://mhs-dev.crye-leike.com/test.php

Thanks for the pointer to extract() though, I had never used it
before.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to