Description

Category: Bug

One of $HTTP_*_VARS variables, like $HTTP_GET_VARS, is being used. However, unlike the newer input variables ($_GET, $_POST, etc.), the old $HTTP_*_VARS variables are not implicitly available in functions. In order to access them, you must declare them as global, or use the $GLOBALS array, or use the new $_GET/$_POST/$_COOKIE/$_SERVER/$_ENV/$_SESSION variables instead (recommended).

Example

Wrong function hello_world()
{
    if (empty(
$HTTP_GET_VARS['name'])) {
        
// $HTTP_GET_VARS is always undefined in this context
        
print "Hello, stranger!";
    } else {
        print
"Hello, $HTTP_GET_VARS[name]";
    }
}
Correct
alternative #1
function hello_world()
{
    global
$HTTP_GET_VARS;
    
    if (empty(
$HTTP_GET_VARS['name'])) {
        print
"Hello, stranger!";
    } else {
        print
"Hello, $HTTP_GET_VARS[name]";
    }
}
Correct
alternative #2
(recommended)
function hello_world()
{
    if (empty(
$_GET['name'])) {
        print
"Hello, stranger!";
    } else {
        print
"Hello, $_GET[name]";
    }
}