php监控网站访问状态

来源:互联网 发布:网络电视收看电视频道 编辑:程序博客网 时间:2024/04/30 16:07
/** * 监控网站 */function httpcode($url){    $ch = curl_init();    $timeout = 3;    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($ch, CURLOPT_HEADER, 1);    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);    curl_setopt($ch, CURLOPT_URL, $url);    curl_exec($ch);    return $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);    curl_close($ch);}
//调用
$http_code = httpcode('http://www.baidu.com');//要监控的网站网址if ($http_code != 200) {      echo ("网站出错,管理员正在赶来的路上……");    }

0 0
原创粉丝点击