How can PHP be used to make an HTTP request without displaying the response in the browser?

To make an HTTP request in PHP without displaying the response in the browser, you can use functions like cURL or file_get_contents. By capturing the response in a variable instead of echoing it directly, you can manipulate or process the response data as needed without displaying it to the user.

<?php
// Using cURL to make an HTTP request without displaying the response
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/api');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// Process the response data as needed
// For example, decode JSON response
$data = json_decode($response, true);

// Other processing steps can be done here