热搜:NVER node 开发 php

初学php遇到的 $HTTP_RAW_POST_DATA 问题

2024-07-20 19:25:01
初学php遇到的 $HTTP_RAW_POST_DATA 问题

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

我做小例子的时候报这种错误,网上都说是把always_populate_raw_post_data' 设置成 '-1',但是我去php.ini里面看了,默认的设置就是-1。哪位大神能够指点一下 


回复讨论(解决方案)

Deprecated 中文释义:过时的
显然你的 php 版本比较高
在高版本 php 的发版说明中都有 $HTTP_RAW_POST_DATA 即将(已经)取消,请改用从 php://input 中读取 的声明

设原来是 $s = $HTTP_RAW_POST_DATA;
应写作 $s = file_get_contents('php://input');
多打几个字而已

$HTTP_RAW_POST_DATA 这个被废弃了,在将来的php版本中还会移除。
让你用 php://input 代替

$GLOBALS['HTTP_RAW_POST_DATA'] 我是用这个写法

This feature has been DEPRECATED as of PHP 5.6.0. Relying on this feature is highly discouraged.
$HTTP_RAW_POST_DATA 包含 POST 提交的原始数据。

一般而言,使用 php://input 代替 $HTTP_RAW_POST_DATA。

并没有用到¥GTTP_RAW_POST_DATA...我只是用到了POST方法

$HTTP_RAW_POST_DATA 已经废弃了
应该用 file_get_contents('php://input');来获取

$GLOBALS['HTTP_RAW_POST_DATA']也一样
说不定一升级版本HTTP_RAW_POST_DATA读出来就空了
全局替换成file_get_contents('php://input')  就行了

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

表示$HTTP_RAW_POST_DATA 已经废弃了,所以应该使用file_get_contents('php://input');来获取

应该是phpstorm破解版不能使用post方法