我目前正在学习PHP,我决定从我的常规编辑器WAMP配置切换到JetBrains PhpStorm,并且在复制粘贴我之前做的几个例子之后我发现它的内置服务器行为不正常(对我来说至少) .

目前我有一个包含两个文件的项目设置:

index.html:

<html>
<body>

<form action="welcome.php" method="post">
    Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name="email"><br>
    <input type="submit">
</form>

</body>
</html>

welcome.php:

<html>
<body>

Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>

</body>
</html>

这是来自W3schools的基本PHP表单example,它在我的WAMP配置上按预期工作,但是当我在输入电子邮件和名称后使用PhpStorm运行它时,我在welcome.php上得到以下输出:

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

Warning: Cannot modify header information - headers already sent in Unknown on line 0
Welcome
Notice: Undefined index: name in D:\deve\PhpstormProjects\untitled\welcome.php on line 4

Your email address is:
Notice: Undefined index: email in D:\deve\PhpstormProjects\untitled\welcome.php on line 5

无论在welcome.php上运行什么php脚本,都会显示 ..$HTTP_RAW.....Cannot modify header information... 警告,但只有PHP 5.6,而我使用PHP 7.0解释器时却没有相同的警告 .

仅当我使用post方法时才会显示 ..Undefined index.. 错误 .

我试过了:

  • 重新安装

  • 尝试了几个不同的PHP版本:PHP 7.0(解决了第一对错误),5.6.20和5.6.16 x86和x64

  • 设置 always_populate_raw_post_data 到不同的值包括 -1 没有区别

值得一提的是,我在WAMP上没有任何问题 . 我在那里使用PHP 5.6.16 . 任何帮助都是赞赏这个东西按预期工作!