问题描述
当我使用此代码打印$GLOBALS
时:
When I print $GLOBALS
using this code:
<?php print_r($GLOBALS); ?>
我得到以下输出:
Array ( [_GET] => Array ( ) [_POST] => Array ( ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) [GLOBALS] => Array *RECURSION* )
在这种情况下,"*RECURSION*
"是什么意思?为什么不同时打印$_SERVER
,$_REQUEST
等?
What does "*RECURSION*
" mean in this case, and why are $_SERVER
, $_REQUEST
, etc. not printed as well?
推荐答案
请参见 PHP手册的这一部分:
<?php
print '$GLOBALS = ' . var_export($GLOBALS, true) . "\n";
?>
这会导致错误消息:嵌套级别太深-递归依赖项?"
This results in the error message: "Nesting level too deep - recursive dependency?"
您已经检索了整个列表-您无法显示其中的一部分(包含递归的列表,因为您可能会超时而不是有意义的事情).
You already have retrieved the whole list - you just cannot display part of it (the one containing a recursion, because you would have timeout rather than anything meaningful).
对于$_REQUEST
,它是$_GET
,$_POST
和$_COOKIE
的派生词,因此其内容是多余的.
When it comes to $_REQUEST
, it is a derivative from $_GET
, $_POST
and $_COOKIE
, so its content is redundant.
编辑:有一个旧的错误/功能,访问它们时似乎在$GLOBALS
中填充了$_SERVER
和$_REQUEST
.因此,尝试访问$_REQUEST
,希望对您有所帮助.无论如何,之后都可以在$GLOBALS
中找到它:ideone.com/CGetH
EDIT: There is an old bug / feature, that seems to be populating $GLOBALS
with $_SERVER
and $_REQUEST
when they are accessed. So try to access $_REQUEST
and hope it helps. Anyway, it can be found in $GLOBALS
after that: ideone.com/CGetH
这篇关于"* RECURSION *"是什么意思?打印$ GLOBALS时是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!