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
PHP5.6报一个郁闷的错,如何解决啊。PHP7没有问题
1个回答
-
我最近一个项目也遇到这样问题,已经解决了,分享出来。
这个问题是在PHP5.6版本遇到的,同样的代码在PHP7版本没有出现。
打开PHP错误日志,看是报下面的错误:
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
找到最近修改的程序,发现了原因,原来是一个AJAX调用的时候没有给POST值。 原来的代码是这样的: $.ajax({ type: "POST", dataType: "json", url: "action.php", data: "", success: function(json){ //do something ... } });
修改后代码: $.ajax({ type: "POST", dataType: "json", url: "action.php", data: "M=1", success: function(json){ //do something ... } });
把data部分赋任意值。
回答者:apfel2016-12-19 12:37:13