Web-Related Variables
PHP automatically creates
variables for all the data it receives in an HTTP request. This can
include GET data, POST data, cookie data, and environment variables.
The variables are either in PHP’s global symbol
table or in one of a number of superglobal arrays, depending on the
value of the register_globals setting in your
php.ini file.
Beginning with PHP 4.2.0, the default
setting for register_globals is
off. With register_globals off,
all the various variables that are usually available directly in the
global symbol table are now available via individual superglobal
arrays. There is a limited set of superglobals and they cannot be
created from a user-level script. The superglobal array to use
depends on the source of the variable. Here is the list:
-
$_GET GET-method variables. These are the variables supplied directly in the URL. For example, with http://www.example.com/script.php?a=1&b=2,
$_GET['a']and$_GET['b']are set to 1 and 2, respectively.-
$_POST POST-method variables. Form field data from regular POST-method forms.
-
$_COOKIE Any cookies the browser sends end up in this array. The name of the cookie is the key and the cookie value becomes the array value.
-
$_REQUEST This array contains all of the above variables (i.e., GET, POST, and cookie). If a variable appears in multiple sources, the order in which they are imported into
$_REQUESTis given by the setting of thevariables_orderphp.ini directive. The default is'GPC', which means GET-method ...
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