【问题标题】:why is $_REQUEST empty为什么 $_REQUEST 为空
【发布时间】:2011-04-18 10:32:11
【问题描述】:

我有 Ubuntu 10.10 和 apache2、php 5.3.3-1 和 mysql 5.1。

我通过 URL 将一些值传递给页面。在那个页面上,如果我执行print_r($_GET),那么我会看到数组内容。但是如果我这样做print_r($_REQUEST) 数组是空的。任何想法为什么会这样?

【问题讨论】:

  • 这是个老问题...你试过var_dump($GLOBALS['_REQUEST']);吗?
  • 是的 $GLOBALS['_REQUEST'] 也是空的
  • php.ini 中查看 register_long_arraysauto_globals_jit。有时它会起作用,当您关闭它们时(更改 php.ini 后重新启动服务器)。你有什么价值观?还可以看看下面@PaulP 的回答。

标签: php arrays request


【解决方案1】:

还可以尝试检查 php.ini 中的 "request_order" 选项:

; This directive determines which super global data (G,P,C,E & S) should
; be registered into the super global array REQUEST. If so, it also determines
; the order in which that data is registered. The values for this directive are
; specified in the same manner as the variables_order directive, EXCEPT one.
; Leaving this value empty will cause PHP to use the value set in the
; variables_order directive. It does not mean it will leave the super globals
; array REQUEST empty.
; Default Value: None
; Development Value: "GP"
; Production Value: "GP"
; http://php.net/request-order
request_order = "GP"

【讨论】:

  • 添加了 PHP 手册页的链接。你打败了我,所以我删除了我的答案! :)
  • 感谢问题已解决。 php.ini 中的值是空的,但有趣的是我的服务器上有相同的设置,但在那里它可以工作。 request_order 没有值和 variables_order EGPCS。再次感谢强硬。
  • 嗨 PaulP,我对 Hawkseye 也有同样的问题,但我在我的 php.ini 文件中发现 request_order 已经设置为“GP”,并且 variables_order 也设置为“GPCS”。我没有做任何改变。我重新启动了 PHP 服务器,但仍然无法正常工作。我在 Windows 上使用 nginx 1.4.4 和 PHP 5.5.8。谢谢。
【解决方案2】:

如果您的帖子正文大于 php.ini 中的 post_max_size 或 upload_max_filesize 可能会导致 $_POST 和 $_REQUEST 也为空。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多