lydia sanusi
lydia sanusi

Reputation: 103

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 ?

Upvotes: 1

Views: 1729

Answers (2)

Luyen Vu
Luyen Vu

Reputation: 9

Install mbstring For Php 5.6

sudo apt install php5.6-mbstring

For php 7.0 sudo apt install php7.0-mbstring

Upvotes: 0

Amit Merchant
Amit Merchant

Reputation: 1043

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

Upvotes: 1

Related Questions