note 48570 deleted from language.variables.predefined by nlopess

From: Date: Sun, 15 May 2005 13:37:17 +0000
Subject: note 48570 deleted from language.variables.predefined by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89450@lists.php.net to get a copy of this message
Note Submitter: urbanheroes {at} gmail {dot} com ---- Note that llcooldanny's solution won't make those variables superglobal, so they still can't be used in functions like normal. One solution is to use $GLOBALS["_GET"] instead of $_GET or $HTTP_GET_VARS, which will work in both PHP version after 4.1.0, and in versions before 4.1.0 if you use that solution: <?php if(version_compare(phpversion(), '4.1.0') == -1) { $_POST = &$HTTP_POST_VARS; $_GET = &$HTTP_GET_VARS; $_COOKIE = &$HTTP_COOKIE_VARS; $_REQUEST = array_merge($HTTP_COOKIE_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS); } // In the global scope, they can be used normally in any version: var_dump($_GET); function dump_get() { // This won't work in versions less than PHP 4.1.0, even using the above solution: var_dump($_GET); // This, however, will work in any version: var_dump($GLOBALS["_GET"]); } dump_get(); ?> If you plan to have full backwards- and forwards-compatibility, you can use that solution and the $GLOBALS["_GET"] syntax in place of a check for $HTTP_GET_VARS or $_GET when using superglobals in functions.

« previous php.notes (#89450) next »