Code: Select all
<?php
// make sure site is up
// more code at phuturecode.com
// uncomment to show errors
// error_reporting(-1);
// set the URL
$url="http://examplewebsite.com";
$cl = curl_init($url);
curl_setopt($cl,CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($cl, CURLOPT_TIMEOUT, 3);
curl_setopt($cl,CURLOPT_HEADER,true);
curl_setopt($cl,CURLOPT_NOBODY,true);
curl_setopt($cl,CURLOPT_RETURNTRANSFER,true);
//get response
$response = curl_exec($cl);
curl_close($cl);
if ($response) echo 'site up';
else echo 'site down';
?>