gpt4 book ai didi

php - undefined variable : HTTP_RAW_POST_DATA

转载 作者:IT王子 更新时间:2023-10-29 00:19:46 25 4
gpt4 key购买 nike

当我对 $HTTP_RAW_POST_DATA 做一个简单的回应时,我得到了错误:

Undefined variable: HTTP_RAW_POST_DATA

我在 php.ini 中读到我需要取消勾选

always_populate_raw_post_data = On

但我仍然收到错误消息,我也确实重新启动了 Apache。我正在使用 php 5.3.6

最佳答案

如果您需要访问原始 POST 正文,您应该根据 relevant manual entry 真正倾向于使用 php://input 流而不是 $HTTP_RAW_POST_DATA :

php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Moreover, for those cases where $HTTP_RAW_POST_DATA is not populated by default, it is a potentially less memory intensive alternative to activating always_populate_raw_post_data. php://input is not available with enctype="multipart/form-data".

因此,要使用 php://input 访问 POST 正文:

$post = file_get_contents('php://input');

关于php - undefined variable : HTTP_RAW_POST_DATA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9553168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com