简体   繁体   中英

Call to undefined function yii\helpers\mb_strlen() on PHP in Yii2 Framework

I have an error occurred when i try run my project at the server.

It could not defined mb_strlen() in /var/www/html/amhadm/vendor/yiisoft/yii2/helpers/BaseStringHelper.php

Here is my code in BaseStringHelper.php

 public static function basename($path, $suffix = '')
{
    if (($len = mb_strlen($suffix)) > 0 && mb_substr($path, -$len) == $suffix) {
        $path = mb_substr($path, 0, -$len);
    }
    $path = rtrim(str_replace('\\', '/', $path), '/\\');
    if (($pos = mb_strrpos($path, '/')) !== false) {
        return mb_substr($path, $pos + 1);
    }

    return $path;
}

Can someone guide me how to solve this problem ?

The function mb_strlen() is not enabled by default in PHP . You need to install it manually. Check details here:

http://www.php.net/manual/en/mbstring.installation.php

Install mbstring For Php 5.6

sudo apt install php5.6-mbstring

For php 7.0 sudo apt install php7.0-mbstring

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM