未填充$ _GET,$ _POST和$ _REQUEST [英] $_GET, $_POST and $_REQUEST not being populated
问题描述
我继承了一台运行xitami / pro服务器并安装了PHP 5.2.17的XP机器,因为我认为我可能需要VC6版本。
phpinfo
显示它应该。当我做 www.domain.com/test.php?x=y&z=test
时, $ _ GET
是没有被填充。
$ _ REQUEST
变量也未被填充。如果我将它发布到表单中并发布, $ _ POST
是空的,因为它是 $ _REQUEST
。如果我循环访问 $ _ SERVER
变量并在get上显示它们, QUERY_STRING
填充了get变量。
当我在> print_r
变量,它是空的。我得到: Array()1
然后我升级到了PHP 5.4和相同的东西。
有什么问题?我很茫然,不知道还有什么可以尝试的。 解决方案
配置错误。特别是当使用错误的SAPI(例如,我非常确定 $ _ GET
/ $ _ POST
不可用当使用 PHP CLI 时。
要查看这是否会导致您的问题,请创建一个新的php文件,并插入以下内容:
<?php
echo php_sapi_name();
?>
这种情况返回 CLI
我很确定这会导致你的问题,通过配置你的服务器来使用正确的SAPI来解决它。
我假设您使用
C:\ php_\\php.exe
作为您的PHP解释器。 C:\php\php-cgi.exe
代替。 I inherited an XP machine with xitami/pro server running on it and installed PHP 5.2.17 because I thought I might need the VC6 version.
PHP works and the phpinfo
shows as it should. When I do www.domain.com/test.php?x=y&z=test
the $_GET
is not being populated.
The $_REQUEST
variable is not being populated either. If I post it in a form and post it, the $_POST
is empty as is the $_REQUEST
.
If I loop through the $_SERVER
variables and display them on a get, the QUERY_STRING
is populated with the get variables.
When I do a print_r
on any of the variables, it is empty. I get: Array ( ) 1
I then upgraded to PHP 5.4 and the same thing.
What is the problem? I am at a loss and don't know what else to try.
I would suspect this problem arises when the server is configured wrong. Especially when the wrong SAPI is used (for example, I'm pretty sure $_GET
/$_POST
are not available when using the PHP CLI.
To see if this causes your issue, create a new php file, and insert the following
<?php
echo php_sapi_name();
?>
In case this returns CLI
I'm pretty sure that causes your issues. Solve it by configuring your server to use the correct SAPI.
TL;DR:
I assume you're using C:\php\php.exe
as your PHP interpreter. Try C:\php\php-cgi.exe
instead.
这篇关于未填充$ _GET,$ _POST和$ _REQUEST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!