Global/Super Global Variables in PHP:

In PHP there are so many global variables are defined. Global variable means that variable can be always accessed in a function or in a class or in a file. We also called them as a Super Global Variable.

Here is a list of PHP Super global Variables:

  • $_SERVER
  • $_POST
  • $_GET
  • $_FILES
  • $_COOKIE


You have already learn that the variable which is define outside a function is a global variable which can be accessed globally anywhere in PHP code.

To use them inside a function use “$GLOBAL[index]” array.



The $_SERVER PHP global variable holds all the information about the server like information about header, script location, server name, etc.


 $_REQUEST variable in PHP:

In PHP the $_REQUEST operator is used to send data after submitting the HTML form.

You can use $_REQUEST variable to collect data if you are using “Get” method or you are using “Post” method means it will work for both methods.

Example: The code is divided into two parts the HTML code and the PHP code

In following example we are using POST method and collecting data from $_REQUEST variable

Below is the HTML code of program

Following is the PHP code of program

 $_POST Variable in PHP:

We have already learn the Post method in our “Get and Post method in PHP” topic. So when you are using a post method at that time you have to use $_POST variable to collect data.

$_POST variable is widely use to collect data because the security reasons.

Example: The code is divided into two parts the HTML code and the PHP code

First we create a HTML form and save as “index.html”

Now we will create a PHP page and save it as “send.php”

 $_GET Variable in PHP:

We have already learn the GET method in our “Get and Post method in PHP” topic. When you are sending data using get method than use the $_GET variable to collect the data in PHP.

This variable is used when we want that the data should be display in URL.


            First we are creating a HTML page and save it with index.html name:

Now we are creating “send.php” page because the action is send.php


The “$_FILES”, “$_SESSION”, and “$_COOKIE” we will cover these variables in separate topics.

One response to “Global/Super Global Variables in PHP”

  1. Baldmero J. says:

    I wanted to write you the little bit of word to finally give thanks again on your splendid tricks you have featured here. This has been so pretty generous with you to make openly what exactly a few people could possibly have offered for an e book to end up making some dough on their own, certainly considering the fact that you might have tried it if you decided. Those smart ideas in addition acted to become a easy way to realize that other individuals have similar keenness really like my own to know way more in regard to this problem. I am sure there are thousands of more pleasurable sessions up front for individuals that look into your site.

Leave a Reply

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