Hey all, Today we are going to learn about PHP Super Global Variables and how can we use them.

The Super global variables are those variables which can be access always. we can access these variable in any function, any file.

There are the various type of PHP Super Global Variables, some of them are mentioned here.

1) $GLOBALS :

This is an array where PHP stores every super global variable and we can access those variables from $GLOBALS[index]. Where we replace the index by the name of the Variable.

It is used to access any of super global variable in our script from any PHP file.

2) $_GET :

It is used to access those data which has been submitted from a form by using get method. Or we can say $_GET variable is used to access those data which are known as URL parameters.

3) $_SERVER:

This variable is used to get the information about the path, the header and the locations. Using it, we can access the host address, server name, user agent, script name etc.

4) $_POST :

Just like $_GET variable we also have a $_POST variable, both of these variables behaves same.

The only major difference between these variables is;

– Using $_GET variable we can only access the data which has been sent by Get method .

– At the same time using $_POST we can only access those data which has been sent as post method.

5) $_REQUEST :

Here we have a very interesting variable which is $_REQUEST. Why am i saying it interesting because, using $_REQUEST, we can simply collect data from both type of methods, whether it is Get or Post Method.

6) $_SESSION :

It used to store information (values or data). $_SESSION is used to store data or values on server side. It gets destroyed whenever we close the browser we lose the session information.

7) $_COOKIE:

It used to store information (values or data). $_COOKIE stores the information in the end user’s browser. the cookie data is present at your browser up to expiration date.

One Reply to “How to use Super Variables in PHP?”

Leave a Reply

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