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

Solve the problem that php cannot accept post value

hzc
Release: 2023-03-01 11:50:02
Original
3591 people have browsed it

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 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 application/x-www-data-urlencoded and multipart/form-data, PHP will request the data When passed to $_POST

2. When PHP cannot recognize the

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

3, as long as

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.

4, only when

Content-Type is application/x-www-data-urlencoded, php://input data will follow $_POSTThe data is consistent.

5,

php://input is the same as HTTPRAWPOSTDATA∗∗., but php://input is more efficient than **HTTP_RAW_POST_DATA and does not require configurationphp.ini

6.

httpRequested in the GET format, the body body is empty.

Solution

Modify php.ini

enable_post_data_reading = On

always_populate_raw_post_data = On
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template