topher topher - 1 year ago 848
PHP Question

Call to undefined function mb_strlen() on PHP 7 Ubuntu 14.04

I had a Yii installation that was working fine up until today. I installed updates on my machine today after which this error was being thrown on all pages:

PHP Fatal Error – yii\base\ErrorException

Uncaught Error: Call to undefined function yii\web\mb_strlen() in /application/vendor/yiisoft/yii2/web/ErrorHandler.php:404

I ran
composer update
but the error persists.

I am using yii 2.0.7 on PHP 7 on Ubuntu 14.04. How do I fix this?

Answer Source

The error is a bit of a red herring since mb_strlen() is actually part of the mbstring php extension and not a function in yii2.

In php5 mbstring was part of libapache2-mod-php5.

It seems to be missing from the latest version of libapache2-mod-php7. To fix this install the php7.0-mbstring package:

sudo apt install php7.0-mbstring
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download