This section describes predefined variables, $_GET, $_POST, $_COOKIE, $_REQUEST, and $_SERVER, that contains information included in the HTTP request received by the PHP engine from the Web server.
When the PHP engine is used on a Web server to handle a HTTP request, it converts information submitted
in the HTTP request as predefined variables and pass them to PHP script.
1. $_GET - Associate array of HTTP request information submitted with the GET method.
By default, all browsers submit HTTP requests with the GET method. Input information collected from
Web page forms will be organized into pairs of names and values, which will be attached
to the end of the URL in the first line of the HTTP request.
When the PHP engine receives a HTTP request, it will take those pairs of names and values
from the end of the request URL and store them in the $_GET array as keys and values.
2. $_POST - Associate array of HTTP request information submitted with the POST method.
If a Web page uses the POST method to submit input information collected from its form.
The browser will organize input into names and values and attach them as the HTTP request body.
When the PHP engine receives a HTTP request, it will take those pairs of names and values
from the request body and store them in the $_POST array as keys and values.
3. $_COOKIE - Associate array of submitted as cookies in the HTTP request.
If a browser has cookies received previously from a Web server,
it will automatically attach them in the next HTTP request to the same Web server.
When the PHP engine receives a HTTP request, it will take cookie names and cookie values from the request
and store them in the $_POST array as keys and values.
4. $_REQUEST - Associate array of all elements from $_GET, $_POST, and $_COOKIE.
To help you to get HTTP request input information in a single place,
the PHP engine automatically combines all keys and values from $_GET, $_POST, and $_COOKIE into $_REQUEST.
5. $_SERVER - Associate array of information from the Web server and the HTTP request.
When the PHP engine receives a HTTP request, it will take other information included in the request
and store it in the $_SERVER array as keys and values.
For example, the following keys and values represent information received from the HTTP request:
The PHP engine also gathers additional information from the Web server
and store it in the $_SERVER array as keys and values.
For example, the following keys and values represent information received from the Web server:
The PHP engine also gathers additional information from the operating system where the PHP engine is running
and store it in the $_SERVER array as keys and values.
For example, the following keys and values represent information received from the operating system: