$_GET 已填充但 $_REQUEST 为空 [英] $_GET filled but $_REQUEST is empty

查看:56
本文介绍了$_GET 已填充但 $_REQUEST 为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在 Windows 7 中安装了 nginx 1.4.4 和 PHP 5.5.8.我运行 nginx.exe 和 php-cgi.exe 来运行服务器并工作.当我在 URL 中发送查询字符串时,如果我 print_r($_GET)具有来自查询字符串的值.但是如果我print_r($_REQUEST)$_REQUEST 只是一个空数组.我在stackoverflow中关注了其他一些问题,我发现的只是检查request_order和variables_order.在 php.ini这是我当前在 php.ini 中 request_order 和 variables_order 的配置:

I recently installed nginx 1.4.4 and PHP 5.5.8 in Windows 7. I run nginx.exe and php-cgi.exe to run the server and works. When I send a query string in URL, if I print_r($_GET) it has the value from query string. But if I print_r($_REQUEST), the $_REQUEST is only an empty array. I have followed some other questions in stackoverflow and all I found is checking request_order and variables_order. in php.ini Here is my current configuration in php.ini for request_order and variables_order:

; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
; paid for the registration of these arrays and because ENV is not as commonly
; used as the others, ENV is not recommended on productions servers. You
; can still get access to the environment variables through getenv() should you
; need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order
variables_order="GPCS"

; 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"

我也找到了关闭 auto_globals_jit 的答案,但它不起作用.我有一个工作安装的 xampp 1.8.3,它在 apache 服务器中工作.但是当nginx使用xampp的PHP时,$_REQUEST也是空的.

I also found an answer to turn off auto_globals_jit, but it doesn't work. I have a working installed xampp 1.8.3, which is working in apache server. But when the nginx use xampp's PHP, the $_REQUEST is empty too.

一些文章告诉更改 nginx 配置以在 fastcgi_params 中添加 query_string.但情况是 $_SERVER['QUERY_STRING'] 是空的.但就我而言, $_SERVER['QUERY_STRING'] 包含值.我仍在尝试,但它也不起作用.

Some articles tell to change nginx config to add query_string in fastcgi_params. But the case is the $_SERVER['QUERY_STRING'] is empty. But for my case, the $_SERVER['QUERY_STRING'] contains value. I still try it but it doesn't work either.

还缺少什么?谢谢.

编辑

这是我的 nginx 服务器配置(我使用 Code Igniter,所以我遵循 http://wiki.nginx.org/Codeigniter 用于配置:

Here is my nginx server configuration (I use Code Igniter, so I follow http://wiki.nginx.org/Codeigniter for the configuration:

server {
    listen       80;
    server_name  local.dev.com;
    root   html/dev;
    autoindex on;
    index index.php;

    location / {

        try_files $uri $uri/ /index.php;

        location = /index.php {

            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  QUERY_STRING       $query_string;
            fastcgi_param  SCRIPT_FILENAME D:/nginx/html/dev$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

    location ~ \.php$ {
        return 444;
    }
}

推荐答案

CodeIgniter 从 $_SERVER['REQUEST_URI'] 手动构建 $_GET,当使用协议 REQUEST_URIAUTO(请参阅$config['uri_protocol']).

CodeIgniter manually builds $_GET from $_SERVER['REQUEST_URI'], when used protocol REQUEST_URI or AUTO (see $config['uri_protocol']).

你应该修改nginx的配置,替换一行:

You should modify nginx's config, replace line:

try_files $uri $uri/ /index.php;

 try_files $uri $uri/ /index.php$is_args$args;

解决空$_REQUEST

这篇关于$_GET 已填充但 $_REQUEST 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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