2
$HTTP_GET_VARS and $HTTP_POST_VARS are arrays managed by PHP that contain variables passed via a querystring (everything after the '?' in an URL) or a form. The code snippet above takes everything that is in both arrays and creates a local variable of the same name.
lets say you have the following URL:
http://www.example.com/myscript.php?a=1&b=2&c=3$HTTP_GET_VARS contains three elements:
$HTTP_GET_VARS['a'] = 1
$HTTP_GET_VARS['b'] = 2
$HTTP_GET_VARS['c'] = 3
after this code runs:
if (isset($HTTP_GET_VARS)) {
foreach ($HTTP_GET_VARS as $k => $v) {
$$k = $v;
}
}
3 new variables are created:
$a = 1
$b = 2
$c = 3
Though easy to do, the above loop is considered sloppy coding. No matter what variable is added to the querystring, PHP will automatically create a variable with the same name for you. For security reasons, it is better to explicitly retrieve the variables you need from the $HTTP_GET_VARS array:
$a = $HTTP_GET_VARS['a']
$b = $HTTP_GET_VARS['b']
$c = $HTTP_GET_VARS['c']
To learn more about these and other variables that PHP creates for use in your scripts, I'd recommend checking out
PHP.net's documentation on Predefined Variables