-
-
Save najlepsiwebdesigner/0b6bf61f006d2bbeee5b8de890e8eb9a to your computer and use it in GitHub Desktop.
a simple PHP curl function to get the content type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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