PHP $GLOBALS缺少$_SERVER

根据http://www.php.net/manual/en/reserved.variables.globals.php

An associative array containing references to all variables which are
currently defined in the global scope of the script.

因此,以下代码必须显示$GLOBALS var具有_SERVER,_ ENV(如果在PHP.ini中的variables_order中启用它)和_REQUEST键:

var_dump($GLOBALS); 

结果是:

>在Nginx PHP-fpm下:缺少_SERVER,_ ENV,_REQUEST
>在cli下:缺少_ENV,_REQUEST

嗯..也许在这个行为的文档中有smth?我查看了每个变量的每个页面

> _SERVER:http://www.php.net/manual/en/reserved.variables.server.php
> _ENV:http://www.php.net/manual/en/reserved.variables.request.php
> _REQUEST:http://www.php.net/manual/en/reserved.variables.request.php

我没有发现过这种行为.它为什么这样?

我已经使用debian软件包从http://www.dotdeb.org/ repo安装了PHP(没有手动编译)…目前正在使用Nginx PHP5-fpm运行.
这是一个PHP bug吗?

解决方法:

我在PHP.net网站上创建了一个bug,PHP团队回答:https://bugs.php.net/bug.php?id=65223

摘要

This is not a bug. super-globals (aka. auto globals) are not added
to symbol tables by default for performance reasons unless the parser
sees need. i.e.

<?PHP $_SERVER; print_r($GLOBALS); ?>

will list it. You can also control this using auto_globals_jit in
PHP.ini:
07001

谢谢PHP团队所以回答这么快!

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...