$_GET, $_POST and $_REQUEST not being populated

假装没事ソ 提交于 2019-12-24 03:23:24

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15092581/get-post-and-request-not-being-populated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!