Home > Article > Backend Development > php super global variables
Many predefined variables in PHP are "superglobal", which means they are available throughout the entire scope of a script. They can be accessed within a function or method without executing global $variable;.
These super global variables are:
$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION
$GLOBALS This kind of global variable is used in any PHP script Positional access to global variables (either from a function or method).
PHP stores all global variables in an array named $GLOBALS[index]. The name of the variable is the key of the array.
<?php $x = 75; $y = 25; function addition() { $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y']; } addition(); echo $z; ?>