<?php
/**
 * 文件工具类
 */

namespace Common\Util;
class FileUtil extends CommonUtil
{
    /**
     * @param $file
     * @return bool
     */
    public static function check_file_exists($file)
    {
        if (stripos($file, 'http') === 0) {// 远程文件
            $header = get_headers($file, true);
            return isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'));
        } else {// 本地文件
            return file_exists($file);
        }
    }

}

相关文章: