Php writes the registration interface, the front end uses the format of ajax, and the post request sends json,php how to get the parameters.

{

username: "11",
password: "222"

}

php:

$username = isset($_POST["username"]) ? $_POST["username"] : "";
$password = isset($_POST["password"]) ? $_POST["password"] : ""; 

is it impossible to get it?

Apr.01,2021

$raw = file_get_contents('php://input');
$json = json_decode($raw,true);

print_r($json);

take a look at the error message


press @ xialeistudio method


 json_decode($_POST,TRUE); 
json
Menu