Superglobals
Variables that come into PHP arrive inside one of several special arrays known collectively as the superglobals , so named because they are available throughout your script, even inside objects and other arrays. Superglobals include form data sent from your visitor, cookie data, session information, local server information, and more, making them good to keep around. Superglobals were not available in PHP prior to v4.1, but there were older alternatives that provided much of the functionality. Superglobals are superior, though, so it is recommended that all new scripts use them.
There are nine superglobal arrays available for use, categorized by type of variable. These are shown in Table 5-2.
Table 5-2. The superglobal arrays
Name |
Functionality |
---|---|
|
Contains all variables sent via a HTTP GET request. For example, a URL of |
|
Contains all variables sent via a HTTP POST request. This is similar to the old |
|
Contains all variables sent via a HTTP POST file upload. This is similar to the old |
|
Contains all variables sent via HTTP cookies. This is similar to the old |
Get PHP in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.