解决报错:Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in

本文解决了在使用PHP进行网页AJAX请求时遇到的两个常见问题:一是自动填充$HTTP_RAW_POST_DATA的废弃警告,建议在php.ini中设置always_populate_raw_post_data为-1,并使用php://input流代替;二是关于无法修改已经发送的头部信息的警告,通常在发送内容前调用header()函数时出现。通过调整PHP配置,这些问题可以得到有效的解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在通过网页ajax的方法报错

<br />
<b>Deprecated</b>:  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 <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />


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

解决方法
在php.ini里将always_populate_raw_post_data=-1来隐藏warning;
打开php.ini 开启 always_populate_raw_post_data = 1 重启php即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值