This article introduces three ways to get POST data from PHP, the first method is $_post, the second method is to use File_get_contents, the third method is to use the global variable $globals, see below for details
Three ways to get post data from PHP
Method One, $_post
$_post or $_request stores the data in PHP in the form of a key=>value format.
Method two, using file_get_contents ("Php://input")
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 is used for any data received by the post in PHP. Without considering Content-type, including binary file streams is also possible.
Compared to $http_raw_post_data, it brings less pressure to memory and does not require any special php.ini settings.
Php://input cannot read the post data content-type is multipart/form-data, you need to set the Always_populate_raw_post_data value in php.ini to ON.
The php://input cannot read $_get data. This is because the $_get data is written as Query_path in the Path field of the HTTP request header (header) instead of the body part of the HTTP request.
Method Three, use global variable $globals[' http_raw_post_data ']
The $globals[' Http_raw_post_data ' store is the raw data that is sent to the POST.
But whether or not to save the POST data in $globals[' Http_raw_post_data '] depends on the settings of Centent-type, only if PHP is in an unrecognized content-type case. The POST data will be filled in the variable $globals[' http_raw_post_data '] as it is, and the variable is empty like content-type=application/x-www-form-urlencoded.
In addition, it is also unable to read the post data of Content-type to Multipart/form-data, but also to set the Always_populate_raw_post_data value in php.ini to ON, PHP will always fill in the post data into the variable $http_raw_post_data.
The above is the whole content of this article, I hope that everyone's study has helped.