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

安稳与你 提交于 2019-12-10 17:33:16

问题


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?


回答1:


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 libapache2-mod-php7. To fix this install the php7.x-mbstring package where x is your version:

sudo apt install php7.x-mbstring

You may need to restart Apache after this install.




回答2:


For PHP7.1

Debian flavours

sudo apt-get install php7.1-mbstring

RedHat flavours

sudo yum install php7.1-mbstring




回答3:


CentOS/RHEL-based

To get a list of available modules to check the version you need is available:

yum search mbstring

Installing mbstring module:

sudo yum install php-mbstring

This will install the correct version for you for your current php installation.



来源:https://stackoverflow.com/questions/35756821/call-to-undefined-function-mb-strlen-on-php-7-ubuntu-14-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!