note 26957 deleted from language.variables.predefined by philip

From: Date: Sun, 08 Dec 2002 02:04:08 +0000
Subject: note 26957 deleted from language.variables.predefined by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-40495@lists.php.net to get a copy of this message
<?php /* Script Name: register_globals.php Description: This script when included at the top of any PHP program makes the following variables available 1. HTTP_*_VARS 2. $_* 3. POST, GET, etc.. variables available just by name ie: "http://www.domain.com/my_php_script.php?id=100" will make the following valid $HTTP_GET_VARS["id"] = $_GET["id"] = $id = 100 No matter register_globals is on or off in php.ini The only limitation is that in PHP versions older than 4.1.0 $_* arrays are not superglobals and if used in a non-global scope must be made available by the 'global' keyword before being used. Author: Sherif Gayed Date: 19/11/2002 */ if(isset($_SERVER) === TRUE){ $HTTP_SERVER_VARS = $_SERVER; $HTTP_GET_VARS = $_GET; $HTTP_POST_VARS = $_POST; $HTTP_COOKIE_VARS = $_COOKIE; $HTTP_POST_FILES = $_FILES; $HTTP_ENV_VARS = $_ENV; $HTTP_SESSION_VARS = $_SESSION; } else{ $_SERVER = $HTTP_SERVER_VARS; $_GET = $HTTP_GET_VARS; $_POST = $HTTP_POST_VARS; $_COOKIE = $HTTP_COOKIE_VARS; $_FILES = $HTTP_POST_FILES; $_ENV = $HTTP_ENV_VARS; $_SESSION = $HTTP_SESSION_VARS; } $g = array($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES, $_ENV, $_SESSION); for($i = 0; $i < count($g); $i++){ $a = $g[$i]; if(is_array($a) === TRUE){ reset($a); for(;list($key, $value) = each($a);){ $$key = $value; } } } ?>

« previous php.notes (#40495) next »