function Check($url){ $ch = curl_init(); $timeout = 10; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1);//将文件的信息作为数据流输出 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);//将获取的信息以字符串返回 curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);//设置等待时间 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);//禁止验证对等证书 $contents = curl_exec($ch); //echo $contents; // // if (preg_match("/404/", $contents)){ // return false; // } $http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);//获取请求状态码 curl_close($ch); if($http_code != '200'){ return false; } return true; }