Getting JSON POST Data with PHP

When a JSON POST is sent with PHP, it is not possible to receive it with $_POST.

Let's write an example JSON POST operation.

fetch(``, {
    method: POST,
    body: JSON.stringfy({
        name: 'phpExample.NET'

Now you can receive and process this data in api.php as follows;


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

There are no comments, make the firs comment