我最近在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的当前配置:
; 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"
Run Code Online (Sandbox Code Playgroud)
我也找到了关闭auto_globals_jit的答案,但它不起作用.我有一个正在安装的xampp 1.8.3,它在apache服务器上运行.但是当nginx使用xampp的PHP时,它$_REQUEST
也是空的.
有些文章告诉你更改nginx配置以在fastcgi_params中添加query_string.但情况$_SERVER['QUERY_STRING']
是空的.但对于我的情况,$_SERVER['QUERY_STRING']
包含值.我仍然尝试它,但它也不起作用.
什么仍然缺少?谢谢.
编辑
这是我的nginx服务器配置(我使用Code Igniter,所以我按照http://wiki.nginx.org/Codeigniter进行配置:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
当使用协议REQUEST_URI或AUTO时, CodeIgniter 手动构建$_GET
(请参阅$_SERVER['REQUEST_URI']
$config['uri_protocol']
)。
您应该修改 nginx 的配置,替换行:
try_files $uri $uri/ /index.php;
Run Code Online (Sandbox Code Playgroud)
到
try_files $uri $uri/ /index.php$is_args$args;
Run Code Online (Sandbox Code Playgroud)
解决空的问题$_REQUEST