Skip to content

Instantly share code, notes, and snippets.

@aquasmit
Forked from james2doyle/simple-curl.php
Created November 17, 2016 14:47
Show Gist options
  • Save aquasmit/e028e0f61477a9247c40cc3e4ae9f926 to your computer and use it in GitHub Desktop.
Save aquasmit/e028e0f61477a9247c40cc3e4ae9f926 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