1、global一般用在函数内,将外部变量参数传递至函数内部,用法为:
<?php
$name = "why";
function changeName(){
global $name;
$name = "what";
}
changeName();
echo "my name is " . $name . "<br/>";
?>
注意:global后面没有“s”,不同于$GLOBALS['a'];
global后面不能直接给变量赋值,必须另取一行给变量赋值;
转载于:https://blog.51cto.com/7300272/1946177