Send GET Request using PHP

file_get_contents function

<?php

$content = file_get_contents('https://httpbin.org/get');

echo $content;

cURL extension

  1. Enable extension in php.ini file:
extension=curl
  1. Send GET request:
<?php

$ch = curl_init('https://httpbin.org/get');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
curl_close($ch);

echo $content;

Leave a Comment

Cancel reply

Your email address will not be published.