"* RECURSION *"是什么意思?打印$ GLOBALS时是什么意思? [英] What does "*RECURSION*" mean when printing $GLOBALS?

查看:209
本文介绍了"* RECURSION *"是什么意思?打印$ GLOBALS时是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用此代码打印$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?

推荐答案

请参见

请记住,$ GLOBALS本身就是一个全局变量.因此,这样的代码将行不通:

Keep in mind that $GLOBALS is, itself, a global variable. So code like this won't work:

<?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时是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆