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://inputCan read unprocessed POST data. Compared with$HTTP_RAW_POST_DATA, it puts less pressure on memory and does not require specialphp.ini settings.php://inputcannot be used forenctype=multipart/form-data
But I summarized it through code comparison and the results are as follows:
## When #1.Coentent-Typeis application/x-www-data-urlencodedandmultipart/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 notmultipart/form-data, PHP will not send http request body data Fill inphp://input, otherwise everything else will work. The length to fill in, specified byContent-Length.
Content-Typeisapplication/x-www-data-urlencoded,php://inputdata will follow$_POSTThe data is consistent.
php://inputis the same as HTTPRAWPOSTDATA∗∗., butphp://input is more efficient than **HTTP_RAW_POST_DATAand does not require configurationphp.ini
httpRequested in theGETformat, thebodybody 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!