W3docs

How to get body of a POST in php?

To get the body of a POST request in PHP, you can use the file_get_contents function and pass it the special php://input stream.

To get the body of a POST request in PHP, you can use the file_get_contents function and pass it the special php://input stream. This will read the raw POST data from the request.

Here is an example of how you can use this to get the body of a POST request:

How to get body of a POST in php?

<?php

$body = file_get_contents('php://input');

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Learn object oriented PHP</div>

You can then use $body as a string variable that contains the body of the POST request.

Note: This method can be used to read the body of any type of request, not just POST requests.