Superglobal Variables
Before you actually build a form and use it to acquire data, we need to make a small detour and look at superglobal variables. We first met global variables in Hour 6, "Functions." A global variable is any variable declared at the "top level" of a script—that is, declared outside a function. Superglobal variables are arrays built in to PHP. They are populated for you automatically with useful elements, and they are available in any scope. You can access a superglobal array within a function or method without using the global keyword. We will encounter superglobal variables throughout the rest of this book. Table 10.1 provides a summary.
Table 10.1. PHP Superglobal Arrays|
$_COOKIE | Contains keys and values set as browser cookies | $_ENV | Contains keys and values set by the script's shell context | $_FILES | Contains information about uploaded files | $_GET | Contains keys and values submitted to the script using the HTTP get method | $_POST | Contains keys and values submitted to the script using the HTTP post method | $_REQUEST | A combined array containing values from the $_GET, $_POST, and $_COOKIES superglobal arrays | $_SERVER | Variables made available by the server | $GLOBALS | Contains all global variables associated with the current script |
|