输出
122Notice: Undefined variable: b in D:/phpstudy/test/shili.php on line191array(7) { ["GLOBALS"]=> *RECURSION* ["_POST"]=> array(0) { } ["_GET"]=> array(0) { } ["_COOKIE"]=> array(0) { } ["_FILES"]=> array(0) { } ["a"]=> int(2) ["php_errormsg"]=> string(21) "Undefined variable: b"}所以在函数中访问全局变量可以通过
1global关键字声明
2直接使用$GLOBALS[]
注意,global $a 其实 类似于 $a=&$GLOBALS['a'] 所以unset的时候只是unset全局变量a的引用。
新闻热点
疑难解答