public function gethttpcode($url){ $ch = curl_init (); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_NOBODY, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_exec($ch); $httpcode=intval(curl_getinfo($ch,CURLINFO_HTTP_CODE)/100); if($httpcode==4 || $httpcode==5 || $httpcode==0){ return false; } return true; }