Log in / create account | Login with OpenID
DocForge
Programmer's Wiki

PHP/Superglobals

From DocForge

< PHP

Beginning with PHP version 4.1, a set of global predefined arrays are available to provide access to server information. These arrays, plus one which provides a reference to all globals, are commonly referred to as "superglobals". There is no mechanism in PHP for user-defined superglobals.

Superglobals are always in scope without using the PHP/global keyword.

$GLOBALS
Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the variables.
$_SERVER
Variables set by the web server or otherwise directly related to the execution environment of the current script.
$_GET
Variables provided to the script via the requested URL query string.
$_POST
Variables provided to the script via HTTP POST.
$_COOKIE
Variables provided to the script via HTTP cookies.
$_FILES
Variables provided to the script via HTTP post file uploads.
$_ENV
Server environment variables available to the script. These are typically determined by the web server and the user space it executes within.
$_REQUEST
Variables provided to the script via the GET, POST, and COOKIE input mechanisms. These shouldn't automatically be trusted.
Do you have information or insights to contribute to this article? Please feel free to edit this page. Ask questions or contribute to the discussion on this article's talk page.