Difference between $_XXX and $HTTP_XXX_VARS

Almost every PHP developer is familiar with $_POST and $HTTP_POST_VARS arrays. Can you tell any significant difference between them? Well, you may think that there is no difference except that the former one was supported after PHP 4.1.0. But the truth is they have one very significant difference between them.

$_POST is a superglobal array and it is also known as an autoglobal array. That makes it available under any scope. Whether you are calling them inside a class, or function you need to declare it as global $_POST.

The $HTTP_POST_VARS is not a superglobal array in truth. If you want to access it inside any function, you must declare it as global. Otherwise it will be considered as a normal array in current function scope which is not what you actually want.

$HTTP_POST_VARS will not be considered as a superglobal array until register_global is turned on.

The same difference exists between their peers like $_GET and $HTTP_GET_VARS, $_FILES and $HTTP_POST_FILES, $_COOKIE and $HTTP_COOKIE_VARS, $_SESSION and $HTTP_SESSION_VARS.

If you are not aware of these difference, you script may fall into severe compatibility problem and you may spend many hours to debug it.

Categorized as PHP


  1. Thanks ,
    This tutorial has really cleared my concepts on these two global array.
    i am very greatful to you regarding this.

Leave a Reply to Gautam kumar gupta Cancel reply

Your email address will not be published. Required fields are marked *