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.
Latest posts by Ashwani Kumar (see all)
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023
- Top DevOps Trainers in Netherlands and Amsterdam - October 9, 2022