1

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 ?

Yupik
  • 4,932
  • 1
  • 12
  • 26
lydia sanusi
  • 103
  • 1
  • 1
  • 8
  • Possible duplicate of [Call to undefined function mb\_strlen() on PHP 7 Ubuntu 14.04](https://stackoverflow.com/questions/35756821/call-to-undefined-function-mb-strlen-on-php-7-ubuntu-14-04) – Ariful Haque Feb 23 '18 at 04:08

2 Answers2

1

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

Amit Merchant
  • 1,045
  • 6
  • 21
0

Install mbstring For Php 5.6

sudo apt install php5.6-mbstring

For php 7.0 sudo apt install php7.0-mbstring

Luyen Vu
  • 9
  • 1