当前位置:首页 > 服务器技术 > IIS

在PHP 5.2.6 / IIS CGI中清空$_POST数组

我在Windows XP上使用PHP 5.2.6 w / IIS遇到了一个非常奇怪的问题(尝试过CGI和ISAPI).我正在使用默认的php.ini设置运行全新安装.

首先,假设以下(丑陋但有效)的HTML代码:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="test1" value="foo" />
<input type="hidden" name="test2" value="bar" />
<input type="submit">
</form>
<br /><br />
<pre>
<?php print_r($_POST); ?>
</pre>

提交表单时,我希望它能够显示一个包含两个隐藏变量的数组.相反,我看到的只是一个空数组.如果我将form方法更改为“get”并将print_r($_ POST)更改为print_r($_ GET),我看到数组项没有问题.

我尝试了诸如<?php print file_get_contents('php:// input')之类的变体; ?&GT和<?php echo print_r($HTTP_POST_VARS); ?&GT无济于事.任何想法可能存在的想法?

解决方法:

好吧,如果它是任何安慰,你的代码可以在PHP5中与Apache一起工作.

一个快速谷歌透露了其他几个有同样问题但没有明确解决方案的人 – 最接近的是this ……

Check your IIS configuration and see what verbs are permitted for PHP.
My guess is that POST isn’t included. You should have GET and POST
enabled at a minimum, or just make your life easy and allow all verbs.

如果找到解决方案,请务必更新您的问题;我相信其他人会受益.


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!