Share
ShareSidebar
2011-10-29 00:33:48 +0

Check if URL exists with PHP and CURL

function check_url($url) {
        $curl
= curl_init($url);
        curl_setopt
($curl, CURLOPT_NOBODY, true);
        $result
= curl_exec($curl);
       
if ($result !== false) {
            $statusCode
= curl_getinfo($curl, CURLINFO_HTTP_CODE);
           
if ($statusCode == 404) {
                echo
"Doesn't Exist";
           
} else {
                echo
"Exist";
           
}
       
} else {
            echo
"Doesn't Exist";
       
}
   
}

Rate this post

You must be registered to vote first

Other posts

Comments

chaddelange
chaddelange 2012-08-09 05:45:20

Nice

+0

Comment