<?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);
}?>
使用方法:
<?php echo httpcode('https://lanyes.org');?>
如果显示为200则正常,如果显示其它值表示不正常;$timeout后面的3是设置超时秒数。
欢迎光临 熙海啵啵 (http://cece56.cn/) | Powered by Discuz! X3.4 |