Predefined Variables
Example 1 — $_SERVER
Request method: GETScript path: /infost440/index.php
$_SERVER['REQUEST_METHOD'] identifies the HTTP request method$ for this page. _SERVER['SCRIPT_NAME'] contains the current script’s path.
Example 2 — $_GET
Read a visitor from the URL query string or return guest if there is no visitor.Visitor: Guest
If $_GET contains query-string parameters, "predefined.php?query=string". The following Url will add a visitor to this page and return the visitor as $visitor.
Click here to try! Visitor: GuestExplanation
Predefined variables are supplied by PHP. Some can be used as is. Some can be overloaded for customizaton.Superglobals such as $_SERVER and $_GET are accessible throughout a script, including inside functions. They provide server details needed for database and form functions. The returned data depends on the environment, file path, or function so this example checks for missing values and escapes request text before displaying it.