Home>Article>Backend Development> Solve the problem that php cannot accept post value

Solve the problem that php cannot accept post value

hzc
hzc Original
2020-06-04 17:15:25 3506browse

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

2. When PHP cannot recognize the

Content-Typetype, the corresponding data in the http request package will be filled in the variable$HTTP_RAW_POST_DATA.

3, as long as

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.

4, only when

Content-Typeisapplication/x-www-data-urlencoded,php://inputdata will follow$_POSTThe data is consistent.

5,

php://inputis the same as HTTPRAWPOSTDATA∗∗., butphp://input is more efficient than **HTTP_RAW_POST_DATAand does not require configurationphp.ini

6.

httpRequested in theGETformat, thebodybody is empty.

Solution

Modify php.ini

enable_post_data_reading = On always_populate_raw_post_data = On

Restart 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn