php-提示-Call-to-undefined-function-fnmatch-解决

今天上线的项目出现了如下报错信息: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()错误问题了

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理