http://php.net/manual/en/language.variables.scope.php
This can cause some problems in that people may inadvertently change a global variable.
這是為了避免無意間改變到全域變數。
<?php
$a=123; /* global scope 全域範圍 */
function test() {
echo $a; /* reference to local scope variable
so output nothing */
echo $GLOBALS['a']; // 123
global $a;
echo $a; // 123
$a = 456;
echo $a; // 456
}
test();
?>