您的位置:首页 > 理论基础 > 计算机网络

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

2017-03-10 12:25 525 查看
“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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐