检测远程文件是否存在

function check_remote_file_exists($url) {
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_NOBODY, true);
    $result = curl_exec($curl);
    $found = false;
    if ($result !== false) {
        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);  
        if ($statusCode == 200) {
            $found = true;   
        }
    }
    curl_close($curl);
    return $found;
}
//http://my.oschina.net/cart/

你可能感兴趣的:(检测远程文件)