常用的一些对于文件相关处理

  

一. 判断文件是否存在

// 验证文件是否存在
function existFile($file)
{
    if( empty($file) ) return false;

    if(stripos($file,'http') === 0){
        // 远程图片
        $header = get_headers($file,1);
        return isset($header[0]) && (strpos($header[0],'200') || strpos($header[0],'304')) && stripos($header[0],'OK');
    }else{
        // 验证是否有中文
        if(preg_match("/([\x81-\xfe][\x40-\xfe])/", $file, $match)){
            $file = iconv('UTF-8', 'GBK', $file);
        }
        return file_exists($file);
    }
}

  注: 匹配字符串全部是中文 

preg_match_all("/^([\x81-\xfe][\x40-\xfe])+$/", $str, $match)

  

 

相关文章:

  • 2022-12-23
  • 2022-01-02
  • 2021-12-16
  • 2022-02-07
  • 2021-08-05
  • 2022-03-08
  • 2021-05-24
  • 2021-05-21
猜你喜欢
  • 2021-09-29
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-01-06
  • 2021-06-28
相关资源
相似解决方案