Difference between $GLOBALS['HTTP_RAW_POST_DATA'] and $_POST
$_POST: An array of variables passed via the HTTP POST method. is an automatic global variable.
$GLOBALS['HTTP_RAW_POST_DATA'] : Always generate the $HTTP_RAW_POST_DATA variable containing the raw POST data. This variable is only generated when data of an unrecognized MIME type is encountered. $HTTP_RAW_POST_DATA is not available for enctype="multipart/form-data" form data.
That is basically $GLOBALS['HTTP_RAW_POST_DATA'] and $_POST are the same.
But if the post data is not recognized by PHP, you can use $GLOBALS['HTTP_RAW_POST_DATA'] to receive, such as text/xml or soap and so on.
Supplementary note: The data type recognized by PHP by default is the data type of the application/x-www.form-urlencoded standard.
**************************************************** ********************************
This is what the manual says
always produces variables containing raw POST data. Otherwise, this variable is only generated when data of an unrecognized MIME type is encountered. However, a better way to access raw POST data is php://input. $HTTP_RAW_POST_DATA is not available for enctype="multipart/form-data" form data.
Question: Does $HTTP_RAW_POST_DATA == $_POST ?
According to the manual, the answer should be no.
If not, what is the difference between them?
I know the answer, here:
The RAW / uninterpreted HTTP POst information can be accessed with:
$GLOBALS['HTTP_RAW_POST_DATA']
This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).
That is, basically $GLOBALS['HTTP_RAW_POST_DATA'] is the same as $_POST. But if the post data is not recognized by PHP, you can use $GLOBALS['HTTP_RAW_POST_DATA'] to receive, such as text/xml or soap and so on.
The data type recognized by PHP by default is application/x-www.form-urlencoded. The standard data type
is Content-Type=text/xml. The content of an xml document is submitted to the php server. How to obtain this POST data.
The RAW / uninterpreted HTTP POST information can be accessed with: $GLOBALS['HTTP_RAW_POST_DATA'] This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).
Since PHP only recognizes application/ by default The x-www.form-urlencoded standard data type, therefore, the content of the type such as text/xml cannot be parsed into the $_POST array, so the prototype is reserved and handed over to $GLOBALS['HTTP_RAW_POST_DATA'] to receive.
There is also a php://input that can also achieve this function.
php://input allows reading the raw data of POST. Compared to $HTTP_RAW_POST_DATA, it puts less pressure on memory and does not require any special php.ini settings. php://input cannot be used with enctype="
a.htm
------------------
<form action="post.php" method="post">
<input type="text" name="user">
<input type="password" name="password">
<input type="submit">
</form>
post.php
----------------------------
<? echo file_get_contents("php://input"); ?>
--------------------------------------------------------
Reprint: Reprint address