php判断远程文件是否存在php

/ / 2019-07-17   阅读:2486
function check_file_exists($file){ if(strtolower(substr($file, 0, 4))=='http'){  //远程文件     $header = get_headers($file, true);     return isset($header[0]) &&am...
function check_file_exists($file){
if(strtolower(substr($file, 0, 4))=='http'){  //远程文件
    $header = get_headers($file, true);
    return isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'));
}else{  //本地文件
    return file_exists($file); 
}
}

我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈