PHP判断网页是否已经失效
2018-9-2 乱云飞 评论(0) 浏览(956) 标签: php代码 网页状态
<?php //判断目标网页是否失效 function chkurl($url){ $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 10);//设置超时时间 curl_exec($handle); //检查是否200 $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); if($httpCode != 200) {return false;} else{return true;} curl_close($handle); } $url=$_GET['url']; if(chkurl($url)==true){echo "没有失效,正常显示";} else{echo "已经失效,不能显示";} ?>