今天上线的项目出现了如下报错信息:Call to undefined function fnmatch()
这是由于fnmatch不能在除windows以外非POSIX系统上使用导致的问题,解决思路为:
首先判断fnmatch方法是否存在,存在使用fnmatch方法,不存在使用其他方法来替代fnmatch方法实现,如:
if(!function_exists('fnmatch')) { if (preg_match("#^".strtr(preg\_quote($pattern, '#'),array('\*' => '.*', '\?'=> '.'))."$#i", $id)){ $exceptMatch = true; break; } } elseif (fnmatch($pattern, $id)) { $exceptMatch = true; break; }
根据如上就可以解决Call to undefined function fnmatch()错误问题了