Super global arrays are predefined associative arrays in PHP that are accessible from anywhere in the script, whether inside functions, classes, or included files—without using the global keyword.
They play a critical role in handling form data, server information, sessions, cookies, file uploads, and environment variables.
What Is a Super Global Array?
A super global array is:
- Automatically available in all scopes
- Predefined by PHP
- Always written in ALL CAPS and starts with
_(underscore) - Contains important system, form, or environment data
These arrays are essential for building modern PHP applications.
List of Super Global Arrays in PHP
PHP provides nine super global arrays:
$GLOBALS$_SERVER$_REQUEST$_POST$_GET$_FILES$_ENV$_COOKIE$_SESSION
Let’s briefly explain each one:
1. $GLOBALS
Stores all global variables in a single associative array.
$x = 5;
function demo() {
echo $GLOBALS['x'];
}
demo(); // Output: 5
2. $_SERVER
Contains information about headers, paths, and server environment.
echo $_SERVER['SERVER_NAME'];
echo $_SERVER['REQUEST_METHOD'];
3. $_REQUEST
Contains data from GET, POST, and COOKIE.
echo $_REQUEST['username'];
4. $_POST
Used to collect form data sent using POST method.
$email = $_POST['email'];
5. $_GET
Used for accessing data sent through URL parameters.
$id = $_GET['id'];
6. $_FILES
Handles file uploads.
print_r($_FILES['upload']);
7. $_ENV
Stores environment variables.
echo $_ENV['PATH'];
8. $_COOKIE
Stores cookie data sent by the browser.
echo $_COOKIE['user'];
9. $_SESSION
Used to store information across multiple pages.
session_start();
echo $_SESSION['user_id'];
Why Are Super Global Arrays Important?
✔ Easily access user input
✔ Manage sessions & authentication
✔ Retrieve server and environment details
✔ Handle file uploads
✔ Process cookies and maintain state
Conclusion
Super global arrays are the backbone of interactive PHP applications.
They allow developers to build login systems, handle user input, upload files, manage sessions, and communicate with the server efficiently.
Citations
🔗 View other articles about PHP:
http://savanka.com/category/learn/php/
🔗 External PHP Documentation:
https://www.php.net/manual/en/