$GLOBALS — References all variables available in global scopeAn associative array containing references to all variables which are currently defined in the global scope of the script. The variable names are the keys of the array.看官方对$GLOBALS的定义, 只是引用, 尽量不要向里面存值
补充, $GLOBALS不是不能赋值,是一般情况用来引用全局变量。 你把$i放在函数外面定义,里面引用, 这样就OK了
最好局部变量不要和全局变量同名。