Hello Coders, today we learn about or gain some knowledge about PHP Superglobal Variables or superglobal variables in PHP. In the start of PHP programming we all use these predefined variables but always confused why these we use, some of the explanation with an example, I will show you today for better understanding. So let’s start these,

PHP Superglobal Variables

Complete Reference: PHP Superglobal Variables


This variable holds data with the array of a variable like $GLOBALS[]. It calls hold value using their element indexes. I elaborate this variable on the below example.

On the above example, we define the $a and $b both are global variables which are stored in the variable $c which hold by Global array and call outside the function and also give o/p.


$_SERVER is a global variable which stores the information about headers, paths and script location and also sometimes we use for getting data from the server. Some of the use of the $_SERVER is in below example,



This is very important and used very widely in PHP web programming for transferring data from one page to another page, $_SESSION holds the variable as an array, working with session_start() function. You can check below with an example.


This variable as a name suggests Environment variable and hold the environment variable also like if in you PHP script env variable is user name you can set it like $_ENV[‘username’] of the PHP script.

On such conditions, this not environment set variable because for setting env variable we use putenv() function.

Others Superglobals are you already know very well like $_POST, $_GET.

If you have any improvement on this artical please comment below.

Happy Coding..!

Was this article helpful?

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

3 thoughts on “PHP Superglobal Variables”

Leave a Reply

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