Undefined variable: HTTP_RAW_POST_DATA

前端 未结 2 1365
既然无缘
既然无缘 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条回答
  • 2021-02-05 13:22

    If you get

    Notice: Undefined variable: HTTP_RAW_POST_DATA

    Please open your Server file add find

    $server->service($HTTP_RAW_POST_DATA);
    

    and replace with following 2 lines.

    if ( !isset( $HTTP_RAW_POST_DATA ) ) $HTTP_RAW_POST_DATA =file_get_contents( 'php://input' );
    $server->service($HTTP_RAW_POST_DATA);
    

    I hope this would help.

    0 讨论(0)
  • 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');
    
    0 讨论(0)
提交回复
热议问题