我的独立博客:https://blog.shenchenglin.cn/12.html
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);
}
$code = httpcode($url);
//echo httpcode($url);
if(empty($code)) {
echo'<center><p style="color:#FF0000;">此网站无法访问,请检查输入是否有误<p><center>';
exit;
}
网友评论