Variables
Server configuration and request information—including form parameters and cookies—are accessible in three different ways from your PHP scripts, as described in this section. Collectively, this information is referred to as EGPCS (environment, GET, POST, cookies, and server).
PHP creates six global arrays that contain the EGPCS information.
The global arrays are:
$_COOKIEContains any cookie values passed as part of the request, where the keys of the array are the names of the cookies
$_GETContains any parameters that are part of a GET request, where the keys of the array are the names of the form parameters
$_POSTContains any parameters that are part of a POST request, where the keys of the array are the names of the form parameters
$_FILESContains information about any uploaded files
$_SERVERContains useful information about the web server, as described in the next section
$_ENVContains the values of any environment variables, where the keys of the array are the names of the environment variables
These variables are not only global, but are also visible from
within function definitions. The $_REQUEST array is also created by PHP
automatically. The $_REQUEST array
contains the elements of the $_GET,
$_POST, and $_COOKIE arrays all in one array variable.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access