Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created December 6, 2014 17:05
Show Gist options
  • Save james2doyle/8ce9b2d8595f17ee0df6 to your computer and use it in GitHub Desktop.
Save james2doyle/8ce9b2d8595f17ee0df6 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