php 判断远程文件是否存在

 PHP基础  2023-01-07  admin  417  562

php 判断远程文件是否存在

if (!function_exists('check_remote_file_exists')) {
    /**
     * 判断远程文件是否存在.
     * @param $url string http或https开头的绝对地址
     * @return string
     * @Date: 2020-07-31 16:47:06
     * @Author: code.cent123.com
     */
    function check_remote_file_exists($url)
    {
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_NOBODY, true);
        //curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
        $result = curl_exec($curl);

        //print_r($result);
        $bool = false;
        if ($result !== false) {
            $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            if ($statusCode == 200) {
                $headInf = get_headers($url, 1);
                $time = strtotime($headInf['Last-Modified']);
                if ($time + 2 < time()) {
                    $bool = true;
                }
            }
        }
        curl_close($curl);

        return $bool;
    }
}


如果文章对您有帮助,点击下方的广告,支持一下作者吧!

转载必须注明出处:

php 判断远程文件是否存在 —— code.cent123.com

相关推荐


酷炫的倒计时客户端

QQ: 425100867捐赠开发者:

go 的加减乘除运算注意事项,及相互转化问题

packagemain import( &quot;fmt&quot; ) funcmain(){ varintAint=10 varintBint=9 varfloatAfloat64=10 varfloatBfloat64=9 //在Go语言中,操作数的类型必须匹配。也就是说,进行运算时,操作数的类型必须一致或能够进行合理的转换。 //具体来说

AI人脸替换工具离线版V6.0 最新版下载

AI人脸替换工具离线版V6.0 最新版下载下载 解压 双击运行roop_rope_facefusion_V60.exe 文件即可下载链接:https://pan.quark.cn/s/be7953632126AI人脸替换工具离线版V6.0

Android各个版本与API等级之间的对应关系

API等级 1 - 3:Android 1.0 (Astro,也被称为“铁臂阿童木”)Android 1.1 (Petit Four,即“花色小蛋糕”)Android 1.5 (Cupcake)API等级 4:Android 1.6 (Donut)API等级 5 - 7:Android 2.0/2.0.1/2.1 (Éclair)API等级 8:Android 2.2/2.2.3 (Froyo)A