Jun 10
4
What are all the variables predefined in PHP?
There are many predefined variables available in PHP. These variables represent everything from external variables to built-in environment variables, last error messages to last retrieved headers. Some of the predefined variables in php are as follows.
Superglobals are built in variables those are always available in all scopes. These variables are $_GLOBALS, $_SERVER, $_GET, $_POST, $_FILES, $_COOKIE, $_SESSION, $_REQUEST, $_ENV. Some other predefined variables in php are $php_errormsg,$HTTP_RAW_POST_DATA, $http_response_header,$argc adn $argv.
Superglobals were introduces in the php 4.1.0. Superglobals are not required to mention as global $variable to access them in the functions or methods. Superglobals cannot be used as variable variables inside functions or class methods. Following is the brief description of each superglobals variables.
$GLOBALS – It is an associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are keys of this array.
$_SERVER – It is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the CGI 1.1 specification, so we should be able to expect those.
$_GET – It is an associative array of variables passed to the current script via the url parameters.
$_POST – It is an associative array of variables passed to the current script via the http post method.
$_FILES – It is an associative array of items uploaded to the current script via the HTTP POST method.
$_REQUEST – It is an array that by default contains the contents of 4_GET, $_POST and $_COOKIE.
$_SESSION – Is is an associative array containing session variables available to the current script.
$_ENV – It is an associative array of variables passed to the current script via the environment method. These variables are imported into PHP’s global namespace from the environment under which the PHP parser is running.
$_COOKIE – It is an associative array of variables passed to the current script via HTTP Cookies.
You can reach me through comments section for online interactive class on php predefined and superglobals variables.








