寄存器_globals = off时输出$ GLOBALS

时间:2013-04-28 05:33:55

标签: php

register_globals设置为“off”。

phpinfo()函数:
本地值=关闭
主值=关

$var = "test";
function test()
{
    var_dump($GLOBALS["var"]);  // this prints "test"..
    die;
}
test();

为什么我得到$ GLOBALS [“var”]的输出?

$test = "mytext";
echo $GLOBALS["test"];  // output: "mytext".. why?
die;

感谢您提供信息!

1 个答案:

答案 0 :(得分:3)

因为register_globals控制$_GET$_POST,Cookie,环境和服务器参数是否自动注册为全局变量。它不会禁用$GLOBALS变量;这是一个无法关闭的核心PHP机制。