Re: $GLOBALS example script on php.net
| From: | Richard Quadling | Date: | Sat, 05 Mar 2011 09:33:40 +0000 |
| Subject: | Re: $GLOBALS example script on php.net | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311687@lists.php.net to get a copy of this message | ||
On 5 March 2011 05:44, Ashim Kapoor <ashimkapoor@gmail.com> wrote:
> Dear all,
>
> I was reading this page
> http://php.net/manual/en/reserved.variables.globals.php and I
> found the
> following script there : ----
>
>
> Here's a function which returns an array of all user defined global
> variables:
>
> <?php
> function globals() {
> $globals = $GLOBALS;
> foreach (array(
> 'GLOBALS',
> '_ENV',
> 'HTTP_ENV_VARS',
> '_POST',
> 'HTTP_POST_VARS',
> '_GET',
> 'HTTP_GET_VARS',
> '_COOKIE',
> 'HTTP_COOKIE_VARS',
> '_SERVER',
> 'HTTP_SERVER_VARS',
> '_FILES',
> 'HTTP_POST_FILES',
> '_REQUEST'
> ) as $var) {
> unset($globals[$var]);
> }
>
> return $globals;
> }
> ?>
>
> I think that this script UNSETS each supergobal variable,but page says that
> it returns ALL user defined vars ? Can some one tell me how that is ?
>
> Thank you,
> Ashim
>
You are right. The user note is incorrect.
I'll remove it.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY