register_globals设置为“off”。
phpinfo()函数:
本地值=关
主值=关闭
$var = "test";
function test()
{
var_dump($GLOBALS["var"]); // this prints "test"..
die;
}
test();
为什么我得到的$ GLOBALS [ “变种”]输出?
$test = "mytext";
echo $GLOBALS["test"]; // output: "mytext".. why?
die;
感谢您的信息!
对,在你的函数中放置'global $ var;'也可以让你像使用全局变量一样使用它。 – Revent 2013-04-28 05:38:16