Skip to content

Instantly share code, notes, and snippets.

@najlepsiwebdesigner
Forked from james2doyle/simple-curl.php
Created January 13, 2017 18:58
Show Gist options
  • Save najlepsiwebdesigner/0b6bf61f006d2bbeee5b8de890e8eb9a to your computer and use it in GitHub Desktop.
Save najlepsiwebdesigner/0b6bf61f006d2bbeee5b8de890e8eb9a to your computer and use it in GitHub Desktop.
a simple PHP curl function to get the content type
function simple_curl($url)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$content = curl_exec ($ch);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close ($ch);
return $contentType;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment