輸出
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的引用。
新聞熱點
疑難解答