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

2次阅读

共计 421 个字符,预计需要花费 2 分钟才能阅读完成。

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

正文完
 0