最新消息: 新版网站上线了!!!

php检查网址是不是404

     function IsPageNotFound($url)
    {
        $result = false;
 
        $handle = curl_init($url);
        curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
        //
        // Get the HTML or whatever is linked in $url
        //
        $response = curl_exec($handle);
        //
        // Let's check for 404 (File not found)
        //
        $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
 
        if ($httpCode == 404)
            $result = true;
 
        return $result;
    }
  $isPageNotFound = IsPageNotFound("http://www.kuitao8.com/abc/");
                            
                            if ( $isPageNotFound )
                               {
                                 echo "404";
 
                                }

转载请注明:谷谷点程序 » php检查网址是不是404