Undefined variable: HTTP_RAW_POST_DATA

前端 未结 2 1368
既然无缘
既然无缘 2021-02-05 12:49

when I do a simple echo of $HTTP_RAW_POST_DATA i get the error:

Undefined variable: HTTP_RAW_POST_DATA

I read that in php.ini i need to un-tic

2条回答
  •  旧时难觅i
    2021-02-05 13:34

    If you need to access the raw POST body you should really favor the use of the php://input stream over $HTTP_RAW_POST_DATA as per the relevant manual entry:

    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".

    So, to access the POST body using php://input:

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

提交回复
热议问题