What are Super Global variable in php ?

The Super Global Variable are predefined or built in variable in the Php which always accessible , regardless of the scope . It can be accessible any where in the php classes of files .
These super globals are also called Predefined variables
Below are the Super Variables  :


$GLOBALS is the variable which allows you to access the global variable from any where in the php scripts as well as with the function and method too. i.e it references all the variables that have global scope .

Let us consider an example :

$a = 5;     $b = 10;

function multiply() { 
    $GLOBALS[‘c’] = $GLOBALS[‘a’] * $GLOBALS[‘b’]; 
echo $c; 
Output : 50 


It is an super global variables which stores the information about the headers , script locations , path etc …..
I.e  It references  the server and execution environment information.

There exist Several of Server variables which you can simply check through print array functions as

<?php    print_r($_SERVER);     ?>

Few of them are :

$_SERVER[‘PHP_SELF’] : Inform you about currently executing script

$_SERVER[‘SERVER_ADDR’] : Check the IP address

$_SERVER[‘SERVER_NAME’] :  host server name (example.com)

$_SERVER[‘REMOTE_ADDR’ ] : Remote ip address from where the user is viewing the site .

$_REQUEST : Collect the form data either the method is get or post

$_POST : Collect the data from the post method which is much secure .

$_GET : Collect the data via GET method which is accessible via URL.

$_FILES : Collect the file information of the form data such as images , videos etc

$_COOKIE : Cookies are the set of information that is stored in client side browser

$_SESSION : The session is the super global variables which stores the temporally stores the user information on the server

$_ENV: Environment variables.

Enjoy ……….

Leave a Reply

Your email address will not be published.Required fields are marked *