get post data in php javascript 1

get post data in php javascript

if($json = json_decode(file_get_contents("php://input"), true)) {
    $data = $json;
} else {
    $data = $_POST;
}

Here is what the above code is Doing:
1. If the request is a GET request, we’ll get the data from the $_GET array.
2. If the request is a POST request, we’ll get the data from the $_POST array.
3. If the request is a PUT request, we’ll get the data from the php://input stream.
4. If the request is a DELETE request, we’ll get the data from the php://input stream.

Similar Posts