use GuzzleHttp\Client; $client = new Client(); $response = $client->request('GET', 'http://example.com'); $body = $response->getBody(); echo $body;
require_once 'HTTP/Request2.php'; $request = new HTTP_Request2('http://example.com', HTTP_Request2::METHOD_GET); $response = $request->send(); $body = $response->getBody(); echo $body;
$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://example.com'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); echo $response;In this example, cURL library is used to initialize a new cURL handle, and then set various options using curl_setopt() function. Finally, the curl_exec() function is executed to send the request, the response is stored in $response variable, and then cURL handle is closed. The response body is then printed to the screen.