Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a fut

来源:互联网 发布:淘宝特价清仓花架 编辑:程序博客网 时间:2024/06/08 07:39

“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”

在一次写代码的过程中,因为PHP版本不同,5.6情况下。遇见了一个这样的错误后面找了很多种解决办法,下面我将用两种办法 解决这个问题。

解决办法

1、修改配置文件php.ini

always_populate_raw_post_data = -1

修改后图片

重启php服务就OK了

2、修改代码

$postStr = $GLOBALS['HTTP_RAW_POST_DATA']换成 $postStr = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input"); 原理,在php5.6后面的版本 是用php://input来获取原生post参数 (详情参见官网 http://php.net/manual/zh/reserved.variables.httprawpostdata.php)
0 0
原创粉丝点击