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
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 '
echo ‘true’;
echo ‘
‘;
}else{
echo ‘


03. Feb, 2008












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