What is $GLOBALS?
$GLOBALS is a super global variable that may be accessed from anywhere in the PHP script. All global variables are stored in the array $GLOBALS, where index is the global variable name that may be retrieved.
All global variables are stored in an array named $GLOBALS[index] in PHP. The variable’s name is stored in the index.
The example below shows how to use the super global variable $GLOBALS:
Two global variables, $x and $y, are declared in the above code and are given a value. Then, in the GLOBAL array, a function multiplication() is written to multiply the values of $x and $y and store the result in another variable $z.