PHP Super Global Variables

PHP has provided predefined variables which are called super globarl variables. In a PHP website project, there might be situation to store logged in user information, access web url info and server related data. In such cases, super global variables are useful.

PHP Super Global Variables

There are nine types of Super Global Variables exist in PHP. And they are as below.

  1. $GLOBALS
  2. $_SERVER
  3. $_REQUEST
  4. $_GET
  5. $_POST
  6. $_SESSION
  7. $_COOKIE
  8. $_FILES
  9. $_ENV

$GLOBALS

$GLOBALS is a super global variable. It is type of Array variable. And it holds all the global variable name.

$_SERVER

Headers, path and script location related information is stored in the $_SERVER variable. It is also a super global variable.

$_REQUEST

Date sent from one script to another can be obtained using $_REQUEST super global variable. ($_POST,$_GET is widely used over $_REQUEST)

$_POST

Data sent from one script to another using POST method can be obtained using $_POST super global variable.

$_GET

Data seeking to receive from one script to another using GET method can be obtained using $_GET super global variable.

$_SESSION

If a data we want to store temporary such as user’s valid login then $_SESSION super global variable is useful. We can store data in this variable. And this data is available until unless the session is active.

$_COOKIE

It is a super global variable and holds cookie data.