Skip to content
SW Study Warehouse
Home › Blog
Blog

Super Global Variables in PHP (Complete 2026 Guide & Examples)

By Pardeep Patel · November 25, 2026 · 2 min read šŸ‘ 304 Views
PhP
Disclosure: Some links in this guide are affiliate links. We may earn a commission at no extra cost to you.

Mastering super global variables in php helps you build stronger fundamentals and apply best practices immediately. Below is a clear breakdown covering core concepts, step-by-step examples, and key takeaways.

Complete Guide: Super Global Variables In Php

Several predefined variables in PHP are “superglobals”, which means that they are always accessible, regardless of scope – and you can access them from any function, class or file without having to do anything special. PHP super global variable is used to access global variables from anywhere in the PHP script. PHP Superglobal variables are accessible on the same page that defines it, as well as outside the page. While local variable’s scope is within the page that defines it.

The PHP superglobal variables are:

  • $GLOBALS
  • $_SERVER
  • $_REQUEST
  • $_POST
  • $_GET
  • $_FILES
  • $_ENV
  • $_COOKIE
  • $_SESSION
$GLOBALS: $GLOBALS is a PHP super global variable which is used to access global variables from anywhere in the PHP script (also from within functions or methods). PHP stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. $_SERVER[ā€œConstantNameā€] : $_SERVER holds information about headers, paths, and script locations. eg. $_SERVER[ā€œSERVER_PORTā€], $_SERVER[ā€œSERVER_NAMEā€], $_SERVER[ā€œREQUEST_URIā€] $_REQUEST[ā€œFormElementNameā€]: This can be used to collect data with both post and get method. $_POST[ā€œFormElementNameā€] : It is used to collect value in a form with method=ā€postā€>. Information sent from a form is invisible to others.(can check on the address bar) $_GET[ā€œFormElementNameā€] : It is used to collect value from a form(HTML script) sent with method=’get’. Information sent from a form with the method=’get’ is visible to everyone(it display on the browser URL bar). $_FILES[ā€œFormElementNameā€]: It can be used to upload files from a client computer/system to a server. OR $_FILES[ā€œFormElementNameā€][ā€œArrayIndexā€]: Such as File Name, File Type, File Size, File temporary name. $_ENV: $_ENV is a superglobal that contains environment variables. Environment variables are provided by the shell under which PHP is running, so they may vary according to different shells. $_COOKIE[ā€œVariableNameā€]: A cookie is used to identify a user. a cookie is a small file that the server embedded on a user computer. $_SESSION[ā€œVariableNameā€]: A session variable is used to store information about a single user, and are available to all pages within one application.

Key Takeaways & Resources for Super Global Variables In Php

Review the Official PHP Manual for official specifications, or explore our Basic Syntax of PHP for related tutorials.

Found this guide helpful? Support Team StudyWarehouse! Buy Us a Coffee

Pardeep Patel

Hi!, I am Pardeep Patel, an Indian passport holder, Traveler, Blogger, Story Writer. I completed my M-Tech (Computer Science) in 2016. I love to travel, eat different foods from various cuisines, experience different cultures, make new friends and meet other.

Leave a Reply

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