Server-Side PHP: Part 3: $_GET, $_PUT, and $_REQUEST

Server-Side PHP

PHP is a programming language frequently used for server-side web development.


$_GET, $_PUT, and $_REQUEST

Like $_SERVER, there are two other superglobals for accessing content sent to the server $_GET and $_PUT.

Depending on the HTTP method used by the client, data will either be in the $_GET or $_PUT variable.

$_GET

Data sent via the GET method is encoded as part of the requesting URL. Anything sent to the server using this method will be found in the $_GET variable on the server.

$_PUT

Data sent via the PUT method is encoded in the body of the content rather than part of the requesting URL. Similar to $_GET, any data sent via this method will be found in the $_PUT variable.

$_REQUEST as combination of $_GET and $_PUT

Introduced in PHP 4.1.0, the $_REQUEST superglobal variable contains all data from the globals $_GET, $_PUT, and $_COOKIE. While a separate variable, it can be used a shorthand for accessing data passed via either $_GET or $_PUT methods.