Tuesday 21 July 2015

PHP Globals with EGPCS Information

PHP contains so many predefined global variables which is called as super globals. These variables are started with an underscore (_) symbol, for example, $_GET, $_POST and etc. Unlike, user defined global variables, this kind of super globals can be accessed from PHP function without using global keyword or anything.
php_global_variable
Super globals used to contain array of information about form contents, sessions, cookies and also have some environment information, which is called as EGPCS information in short. The expansion of this acronym is shown in the below list.
  • $_ENV – This variable contains an array of details about the server environment. For example, $_ENV[“HOME”], $_ENV[“PATH_INFO”] and etc.
  • $_GET – This will contain the list of parameters sent as query string with the url.
  • $_POST – This will have the form parameters and its values when the form method is specified as post
  • $_COOKIE – The registered cookies will be loaded with this array.
  • $_SERVER – It contains the server information like, $_SERVER[“REQUEST_METHOD”], $_SERVER[“QUERY_STRING”] and etc.
While executing the PHP program, the global array data are loaded in the order specified using variables_order directive of the PHP configuration file php.ini, and we can control this order and can decide about which of these variable is required to be displayed. To get the elements of $_GET, $_POST and $_COOKIE as a whole into an single associative array, we can use another PHP global variable named $_REQUEST.

0 comments:

Post a Comment