Don't miss

Ping Whether Website Exist or Not using PHP?

By on January 24, 2012

Looking to test whether a site link exist or not, use the following function:

function urlExists($url=NULL)
{

if($url == NULL) return false;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode>=200) { return true; }
else { return false; }

}

About Shahzaib Khan

Shahzaib Khan is a serial entrepreneur, specialized in using cutting edge web technologies & social-media strategies to bring products and campaigns from concept to a reality. Diving deep-dives to elicit user requirements, rapidly conceive usability driven products, and apply the latest in social media and lean-development methodologies to bring the results to life.