Home>Article>Backend Development> What should I do if php cannot accept the post information?

What should I do if php cannot accept the post information?

hzc
hzc Original
2020-06-10 10:44:49 2832browse

What should I do if php cannot accept the post information?

Solution to the problem that php cannot accept post information:

This usually occurs when submitting ajax

When we set the ajax parameter contentType: 'application/json; charset=utf-8', we use file_get_contents("php://input") to get the value $_POST, which cannot be obtained.

1. Check the header The information content-type is "content-type:application/x-www-form-urlencoded". This transmission is to submit data in a form and PHP uses the $_POST method to accept it.

2. Check whether the header information content-type is "content-type:application/json". This kind of transmission submits data in json mode. PHP needs to use file_get_contents("php://input") to obtain it. The input stream method accepts

recommended tutorial: "php tutorial"

The above is the detailed content of What should I do if php cannot accept the post information?. 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