note 27563 added to ref.variables

From: Date: Wed, 11 Dec 2002 05:32:00 +0000
Subject: note 27563 added to ref.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-40686@lists.php.net to get a copy of this message
The above code posted by maxim and dekiland doesn't seem to create $_REQUEST in the same manner as described in the PHP Documentation: "An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE". I modified the code slightly. I haven't tested this much, but it seems to work as expected. $evil_vars = Array('GET', 'POST', 'COOKIE', 'SERVER', 'ENV', 'REQUEST', 'SESSION'); $php_version = preg_replace("/[^\d]/", '', phpversion()); for ($i = 0; $i < sizeof($evil_vars); $i++) { if (is_array(${"HTTP_{$evil_vars[$i]}_VARS"})) { foreach (${"HTTP_{$evil_vars[$i]}_VARS"} as $var=>$val) { if($php_version<410) { $GLOBALS["_{$evil_vars[$i]}"][$var] = $val; // following if condition added by D. Friesen if (($evil_vars[$i] == 'GET') || ($evil_vars[$i] == 'POST') || ($evil_vars[$i] == 'COOKIE')) $GLOBALS["_REQUEST"][$var] = $val; } unset($$var); //changed from unset($$key); by dekiland } } unset(${"HTTP_{$evil_vars[$i]}_VARS"}); } -- http://www.php.net/manual/en/ref.variables.php http://master.php.net/manage/user-notes.php?action=edit+27563 http://master.php.net/manage/user-notes.php?action=delete+27563 http://master.php.net/manage/user-notes.php?action=reject+27563

« previous php.notes (#40686) next »