Home>Article>Backend Development> 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 specialphp.ini settings
.php://input
cannot be used forenctype=multipart/form-data
But I summarized it through code comparison and the results are as follows:
## When #1.Coentent-Typeis a
pplication/x-www-data-urlencodedand
multipart/form-data, PHP will request the data When passed to
$_POST
Content-Typetype, the corresponding data in the http request package will be filled in the variable
$HTTP_RAW_POST_DATA.
Content-Typeis 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-Typeis
application/x-www-data-urlencoded,
php://inputdata will follow
$_POSTThe data is consistent.
php://inputis the same as HTTPRAWPOSTDATA∗∗., but
php://input is more efficient than **HTTP_RAW_POST_DATAand does not require configuration
php.ini
httpRequested in the
GETformat, the
bodybody 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!