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

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

问题描述

当我打印 $ GLOBALS 使用此code:

When I print $GLOBALS using this code:

<?php print_r($GLOBALS); ?>

我得到这样的输出:

I get this output:

阵列([_ GET] =&GT;数组()_ POST] =&GT;数组()[_COOKIE] =&GT;数组()[_FILES] =&GT;数组()[GLOBALS] = GT;数组*递归*)

这是什么 *递归* 意味着在这种情况下,为什么是 $ _ SERVER $ _ REQUEST 等不打印呢?

What does *RECURSION* mean in this case, and why are $_SERVER, $_REQUEST, etc. not printed as well?

推荐答案

请参阅的 PHP手册的这一部分:

请即$ GLOBALS是,本身就是一个全局变量。所以,code这样是行不通的:

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.

修改:有一个老的bug /功能,这似乎是填充 $ 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

这篇关于什么*递归*打印$ GLOBALS时,是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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