In PHP, there are some helpful global variables available to developers that contain various elements of HTTP request data. In fact, these aren't just global variables but superglobal, which means they do not need to be declared with the global $var; syntax. They are available in all scopes by default. Some of them are:

Other superglobals are $GLOBALS, $_SERVER, $_FILES, $_SESSION, and $_ENV.

Comparison chart

$_POST versus $_REQUEST comparison chart
Edit this comparison chart$_POST$_REQUEST
Contains POST data only both GET and POST data, as well as contents of $_COOKIE

Special Cases

$_REQUEST is a separate variable from $_GET and $_POST. This means modifying $_GET or $_POST elements at runtime will not affect the elements in $_REQUEST, and vice versa.

When running PHP scripts via the command line, i.e., not as part of serving an HTTP request, $_REQUEST does not include the argv and argc entries. They are only included in the $_SERVER associative array.

Conflicting GET and POST variables

By default $_REQUEST contains data from GET, POST and cookies. If there are conflicts—i.e., the same variable is set separately in GET and POST or POST and Cookie etc.—the conflicts are resolved per the the PHP variables_order configuration directive. The default order is EGPCS (environment, GET, POST, Cookie, Server). This means the variable in $_GET gets precedence over $_POST, which in turn gets precedence over $_COOKIE.


Share this comparison:

If you read this far, you should follow us:

"$ POST vs $ REQUEST." Diffen LLC, n.d. Web. 4 Jan 2018. < >