PHP generally use GET or post value, this article is mainly to share with you why PHP can only accept get receive not post value, hope to help everyone.
A few ways to get post data from PHP
Method 1, the most common method is: $_post[' fieldname '];
Note: only data submitted by content-type:application/x-www-form-urlencoded can be received
Explanation: That is, the data that forms post
Method 2, File_get_contents ("Php://input");
Description
Allows the raw data to be read from the POST.
(This method is only used when testing the tool with the interface if the header is set to Content-type:application/json. )
Compared to $HTTP _raw_post_data, it brings less pressure to memory and does not require any special php.ini settings.
Php://input cannot be used for enctype= "Multipart/form-data".
Explain:
For post data that does not specify Content-type, you can use File_get_contents ("Php://input") to get the raw data.
In fact, this method can be used for any data that is received by the post in PHP. Regardless of the Content-type, including binary file streams is also possible.
So using method Two is the safest method.
Method 3, $GLOBALS [' Http_raw_post_data '];
Description:
always produces $HTTP the _raw_post_data variable contains the original POST data.
This variable is only generated when you encounter data with an unrecognized MIME type.
$HTTP _raw_post_data is not available for enctype= "multipart/form-data" form data
If the data you POST is not recognized by PHP, you can use $GLOBALS [' Http_raw_ Post_data '] to receive,
such as text/xml or soap, and so on
Explanation: the
$GLOBALS [' Http_raw_post_data '] holds the raw data that came in POST.
$_post or $_request holds PHP in the form of a key=>value format for subsequent data.
But whether or not to save post data in $globals[' Http_raw_post_data '] depends on the settings of the Centent-type, that is, the post data must be explicitly indicated content-type:application/ X-www-form-urlencoded,post data is stored in the $GLOBALS [' Http_raw_post_data '].