note 102008 modified in reserved.variables.globals by danbrown

From: Date: Sat, 22 Jan 2011 20:05:31 +0000
Subject: note 102008 modified in reserved.variables.globals by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176013@lists.php.net to get a copy of this message
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; } ?> --was-- Here's a function which returns an array of all user defined global variables: 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; } http://php.net/manual/en/reserved.variables.globals.php

« previous php.notes (#176013) next »