call to undefined function mb_strimwidth

25,428

Solution 1

All mb_* functions are provided by a PHP extension called Multibyte String, internal name mbstring

You probably don't have the extension active or installed. On most Linux distros you can install the package php-mbstring to install and activate this extension.

Apache needs to be restarted afterwards if you are using mod_php

Solution 2

Just got this issue, if you are using linux just install the package php-mbstringand restart Apache.

sudo apt-get install php-mbstring
sudo service apache2 restart

If you are using specific PHP version, you may need to run the following:

sudo apt-get install php7.x-mbstring
sudo service apache2 restart

Replace 7.x by the exact PHP version.

Solution 3

u need to install php-mbstring package try.

check php version

php -v

then check mbstring already install and enable

php -i | grep mbstring

if not installed run this command

sudo apt-get install php-mbstring

if you are php other version example : 7.1, 7.2, 7.0 based on run command like this :

sudo apt-get install php7.1-mbstring 

if you are using nginx server for run laravel .. then check nginx configration file which version u have loaded in conf file..

go to cd /etc/nginx/sites-available and open your configuration file.. if you are loading php7.2 version in nginx conf file..

fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

then u need to install 7.2 mbstring package..

sudo apt-get install php7.2-mbstring 

and restart apache2 server

 sudo service apache2 restart
Share:
25,428

Related videos on Youtube

Yuri
Author by

Yuri

Updated on July 30, 2022

Comments

  • Yuri
    Yuri almost 2 years

    Months ago I made a short code that uses mb_strimwidth() to exactly fit some text into a table cell, putting dots at the end of a truncated string. Now, after some times, I tried to execute that same code and it went out with this error:

    Fatal error: Call to undefined function mb_strimwidth() in ...
    

    I tried to find the mbstring.php file, and when I found the mb_strimwidth() function, I discovered that it is not implemented anymore. How is that possible? But my main question is: how can I get the same result as mb_strimwidth()? I thought to rewrite the function using a loop and mb_strwidth(), but ALL the functions in that mbstring.php file are empty.

  • Yuri
    Yuri over 11 years
    ok, this solved my problem. But I don't understand what happened since last time, when it worked correctly...
  • Michel Feldheim
    Michel Feldheim over 11 years
    You probably updated php, that's distro specific. e.g. installed php-54 packages and removed php packages.
  • Sijan Bhattarai
    Sijan Bhattarai almost 6 years
    I installed the php-mbstring in my machine and restarted the apache as well. I checked my phpinfo() after that but couldn't find php-mbstring there. I am still getting the same issue. Any help?