use GuzzleHttp\Client; $client = new Client(['base_uri' => 'https://example.com']); $response = $client->request('GET', '/api/resource'); $body = $response->getBody(); echo $body;
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $body = $request->getContent(); echo $body;In this example, the createFromGlobals method of the Request class is used to create a new instance of the Request object based on the current HTTP request. The getContent method is then called on this object to retrieve the body content, which is then echoed out. Overall, the getBody method is a useful function for retrieving the body content of HTTP requests and responses in PHP, and is available in various libraries and packages.