calling the undefined function mb_strimwidth

Months ago, I made a short code that uses mb_strimwidth() to exactly match some text in a table cell, putting dots at the end of a truncated line. Now, several times later, I tried to execute the same code, and it exited 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 found that it was no longer implemented. How is this possible? But my main question is: how can I get the same result as mb_strimwidth() ? I thought to rewrite the function with a loop and mb_strwidth() , but ALL the functions in this mbstring.php file are empty.

+5
source share
4 answers

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

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

After using Apache you need to restart if you use mod_php

+16
source

Just got this problem if you are using Linux, just install the php-mbstring package and restart Apache.

 sudo apt-get install php-mbstring sudo service apache2 restart 
+3
source

you need to install the 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 php another example version : 7.1, 7.2, 7.0 based on the run command, for example:

 sudo apt-get install php7.1-mbstring 

if you use the nginx server to run laravel .. then check the nginx configuration file, which version you downloaded to the conf ..

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

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

then you need to install the 7.2 mbstring package ..

 sudo apt-get install php7.2-mbstring 

and restart apache2 server

  sudo service apache2 restart 
+1
source

if you have already installed mbstring, you must call this extension in the php.ini file.

First determine where your php-fpm.ini or php.ini file is located.

Launch command

 php -i | grep php.ini 

it returns you the path to the php.ini file.

eg

 /etc/php.ini 

then open the file using VIM or another editor

 vim /etc/php.ini 

and then add the mbstring extension to the php.ini file

 extension=mbstring.so; 

finally restart php-fpm

 systemctl restart php-fpm 
0
source

All Articles