Re: [PHP4BETA] Global Variable scope within functions
| From: | Chris Adams | Date: | Wed, 10 May 2000 05:08:31 +0000 |
| Subject: | Re: [PHP4BETA] Global Variable scope within functions | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-14707@lists.php.net to get a copy of this message | ||
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.