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!