This article will give you a brief introduction to the reference to the Global keyword of the PHP Global variable. although the comments are short compared with the articles, the principles are quite clear and simple.
This article will give you a brief introduction to the Global keyword reference of PHP Global variables. although the comments are short compared with the articles, the principles are quite clear and easy to understand, especially for those who have some language basics, it is worth summarizing. don't close the customs. start with the question:
$ GLOBALS reference to the PHP manual:
Global variable: $ GLOBALS
Note: $ GLOBALS is applicable to PHP 3.0.0 and later versions.
An array composed of all defined global variables. the variable name is the index of the array.
This is a "superglobal", or it can be described as an automatic global variable. that is to say, $ var1 and $ GLOBALS ['var1'] in the above code refer to the same variable, rather than two different variables!
For example, the instance code is as follows:
-