Need help! php error undefined function fnmatch

I just installed openwrt( x86-64 v18.06.4 ) and php7-cli, then run a php application, it doesn't work and print the info:

     Uncaught Error: Call to undefined function fnmatch()

Is there any way to solve this problem? Thanks for your help very much!

Seems that PHP missin fnmatch function. All you need is to include this in code of that app:

if(!function_exists('fnmatch')) {

    function fnmatch($pattern, $string) {
        return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
    } // end

} // end if

Thanks for reply!
That PHP app is not open source and run with ionCube, so It seems that I can't add those code.

Is there a way to build a openwrt firmware or PHP that support fnmatch?

You need to rebuild PHP to support it OR to contact developer for this workaround.

2 Likes