Check URL Exists in PHP

<?php
function url_exists($url) {
    $handle   = curl_init($url);
    if (false === $handle)
    {
        return false;
    }
    curl_setopt($handle, CURLOPT_HEADER, false);
    curl_setopt($handle, CURLOPT_FAILONERROR, true);
    curl_setopt($handle, CURLOPT_NOBODY, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
    $connectable = curl_exec($handle);
    curl_close($handle);
    return $connectable;
}

$url = 'http://insicdesigns.com/';

if(url_exists($url)){
	echo 'true';
}else{
	echo 'false';
}
?>

Output is

true
PG

Author: admin

Related Post

Digg Delicious Stumbleupon Technorati

No comments yet... Be the first to leave a reply!

Leave a Reply