---
title: "Global Variables - Superglobals"  
description: "Global Variables - Superglobals"  
author: "Anonymous User"  
published: 2018-07-19  
updated: 2018-07-19  
canonical: https://www.mindstick.com/forum/34626/global-variables-superglobals  
category: "php"  
tags: ["web development", "php"]  
reading_time: 1 minute  

---

# Global Variables - Superglobals

why [Global](https://www.mindstick.com/articles/13127/macro-and-microeconomics-concepts-in-relation-to-global-organization-management) [Variables](https://www.mindstick.com/articles/715/php-variables) are Superglobals in [php](https://www.mindstick.com/articles/12149/php-constant-and-php-variables) [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) with a example ?

## Replies

### Reply by Prakash nidhi Verma

PHP Global Variables - Superglobals :

it's a predefined variables in PHP which are always accessible of scope and you can access them from any function and class. The PHP superglobal variables are:

```
$GLOBALS $_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION
```

\

PHP $GLOBALS:

$GLOBALS[index] in PHP it means which is stores all global variables in array. The index holds the name of the variable.

```
<?php
$x =10;
$y =20;
function addition() {
    $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}
addition();
echo $z;
?>
```

\

PHP $_SERVER :

it is holds information about headers, paths and script locations in PHP super global variable.

```
<?php
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
echo "<br>";
echo $_SERVER['HTTP_HOST'];
echo "<br>";
echo $_SERVER['HTTP_REFERER'];
echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
?>
```


---

Original Source: https://www.mindstick.com/forum/34626/global-variables-superglobals

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
