php 判断网站是否可以访问
<?php
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);
}
echo "判断网站能否访问,显示200正常,其它都不对:".httpcode('https://cn.bing.com');
?>
- 上一篇: 啥拦截软件都挡不住?教你杜绝流氓软件弹窗
- 下一篇: mysql同步出错问题