Home >Backend Development >PHP Problem >Solve the problem that php cannot accept post value
When this happens, we need to check the value of the parameter
Content-Type: in our header
php://input
Can read unprocessed POST data. Compared with $HTTP_RAW_POST_DATA
, it puts less pressure on memory and does not require special php.ini settings
. php://input
cannot be used for enctype=multipart/form-data
But I summarized it through code comparison and the results are as follows:
## When #1.Coentent-Type is a
pplication/x-www-data-urlencoded and
multipart/form-data, PHP will request the data When passed to
$_POST
Content-Type type, the corresponding data in the http request package will be filled in the variable
$HTTP_RAW_POST_DATA.
Content-Type is not
multipart/form-data, PHP will not send http request body data Fill in
php://input, otherwise everything else will work. The length to fill in, specified by
Content-Length.
Content-Type is
application/x-www-data-urlencoded,
php://input data will follow
$_POSTThe data is consistent.
php://input is the same as HTTPRAWPOSTDATA∗∗., but
php://input is more efficient than **HTTP_RAW_POST_DATA and does not require configuration
php.ini
httpRequested in the
GET format, the
body body is empty.
Solution
Modify php.inienable_post_data_reading = On always_populate_raw_post_data = OnRestart apache to solve the problem. Recommended: "
PHP Tutorial"
The above is the detailed content of Solve the problem that php cannot accept post value. For more information, please follow other related articles on the PHP Chinese website!