For this reason, I am still skeptical. In this way, global will have different calculation results depending on the PHP version, so the compatibility will be a bit poor.
Found the reason, see this website link
https://www.php.cn/php/php-variables.html
Note: The output value of the above code in the PHP5 version is 15; however, the online instance environment of the PHP Chinese website is the PHP7 version, so the output value should be 10. Because in the latest php7 version, the PHP global variable processing mechanism has been modified, the global keyword in this version can only refer to simple variables. For a detailed introduction to the differences, please see this article:
What are the changes in the global variable mechanism under PHP5 and PHP7? (Code actual test)
The PHP of the following online PHP editors are all versions of PHP7 or above, and the running results are all 15
##
For this reason, I am still skeptical. In this way, global will have different calculation results depending on the PHP version, so the compatibility will be a bit poor.
Found the reason, see this website link https://www.php.cn/php/php-variables.html Note: The output value of the above code in the PHP5 version is 15; however, the online instance environment of the PHP Chinese website is the PHP7 version, so the output value should be 10. Because in the latest php7 version, the PHP global variable processing mechanism has been modified, the global keyword in this version can only refer to simple variables. For a detailed introduction to the differences, please see this article: What are the changes in the global variable mechanism under PHP5 and PHP7? (Code actual test)
$GLOBAL['x'] means to retrieve the value with key name 'x' from array $GLOBAL. Question about your code, where does this array come from?