PHP Superglobal Variables

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

$GLOBALS

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

$_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,

 $_REQUEST

 $_SESSION

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.

 $_ENV

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?
YesNo
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH, my native place in Odisha. I am a Web Programmer by profession and working on more than 50 projects to date. My passion is working on the web-based project using PHP and relate to all CMS and frameworks which is based on PHP.
Posts created 155

2 thoughts on “PHP Superglobal Variables

Leave a Reply

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

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
mariobet - supertotobet - escort -

takip7.com