Fatal error: Call to undefined function mb_strlen()
The function mb_strlen()
is not enabled by default in PHP. Please read the manual for installation details:
http://www.php.net/manual/en/mbstring.installation.php
Call to undefined function mb_strlen() on PHP 7 Ubuntu 14.04
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.
Cannot enable mb_string in PHP
After over 3,5 hours of search, I found the solution!!! I HOPE IT WILL HELP SOMEONE ELSE !!
THE ERROR
So, the problem was that the extension_dir
in the php.ini
file was set to the wrong file. By default, it was to the following:
extension_dir = './'
THE SOLUTION
- Open you terminal
ctrl+alt+t
and type:
php -i | grep extension_dir
In my case, it ouputs:
/user/lib/php/20180731
- Find out your
php.ini
file:
You can do that either by:
<?php
phpinfo();
Or on the terminal
php -i | grep 'php.ini'
- Go to your
php.ini
file and change the following line:
extension_dir = '/full/path/to/your/php/modules'
in my case, it was:
exension_dir = '/usr/lib/php/20180731'
SEE MORE
By the way, you have to do this after installing mbstring
. To do that, You may find useful the following links:
PHP: Call to undefined function mb_strlen() - on custom compiled PHP with mbstring enabled
Fatal error: Call to undefined function mb_strlen()
Call to undefined function yii\helpers\mb_strlen() on PHP in Yii2 Framework
https://askubuntu.com/questions/772397/mbstring-is-missing-for-phpmyadmin-in-ubuntu-16-04
Fatal error: Uncaught Error: Call to undefined function mb_detect_encoding() in Uniform Server with PHP 7.2
The developer of Uniform Server managed to fix the problem, saying so in this post.
Ok.. Thanks for bringing this up.. Looks like made a mistake on the spelling on the extensions folder. Please rename the /core/php72/extentions to /core/php72/extensions and everything should work as expected.. I have updated the module in Sourceforge.
Related Topics
What Security Problems Could Come from Exposing PHPinfo() to End Users
JSON Parse Error with Double Quotes
What Is the Postman-Token Header Attribute in Generated Code from Postman
Replace Deprecated Preg_Replace /E with Preg_Replace_Callback
How to Add Query Parameters in the Zf2/Zf3 Url View Helper
Why I am Getting Error When Getting Booking from Database
Paypal Gateway Has Rejected Request. Security Header Is Not Valid (#10002: Security Error Magento
A PHP/Pthreads Thread Class Can't Use Array
How to Serve Mp3 Files with PHP
Replace Ereg_Replace with Preg_Replace
Detecting File Upload Size on the Client Side
How to Send a Bytearray (From Flash) and Some Form Data to PHP