标签:strip get ipo color bsp span UNC 文件 code
常用的一些对于文件相关处理
一. 判断文件是否存在
// 验证文件是否存在 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)
标签:strip get ipo color bsp span UNC 文件 code
原文地址:https://www.cnblogs.com/xingxia/p/php_file.html