note 20105 added to ref.variables
| From: | dekiland at rilasoft dot com | Date: | Fri, 22 Mar 2002 11:55:28 +0000 |
| Subject: | note 20105 added to ref.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-28074@lists.php.net to get a copy of this message | ||
Excellent and useful code Maxim Maletsky, but there is a small bug fix for it...
<?php
/// by Maxim Maletsky <maxim@maxim.cx>
$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;
}
unset($$var); //changed from unset($$key); by dekiland
}
}
unset(${"HTTP_{$evil_vars[$i]}_VARS"});
}
Double cheers,
dekiland
--
http://www.php.net/manual/en/ref.variables.php
http://master.php.net/manage/user-notes.php?action=edit+20105
http://master.php.net/manage/user-notes.php?action=delete+20105
http://master.php.net/manage/user-notes.php?action=reject+20105