The error “Call to undefined function mb_strcut()” typically occurs with PHP softwares or Laravel projects, when the PHP Multibyte String (mbstring) extension is not installed or enabled in your server environment. Laravel requires this extension for string manipulation with multi-byte characters. To resolve this error, you need to install and enable the mbstring extension.
Here are the steps to do this on various platforms:
Fix “Call to undefined function mb_strcut()” on Linux Ubuntu / Linunx Debian / Linux Mint:
To install and enable the mbstring extension, run the following commands:
sudo apt-get update
sudo apt-get install php-mbstring
After installation, restart the web server:
For Apache:
sudo service apache2 restart
For Nginx:
sudo service nginx restart
sudo service php-fpm restart
Fix “Call to undefined function mb_strcut()” on CentOS/RHEL/Fedora:
First, install the mbstring extension:
sudo yum install php-mbstring
or
sudo dnf install php-mbstring
Then, restart the web server:
For Apache:
sudo systemctl restart httpd
For Nginx:
sudo systemctl restart nginx
sudo systemctl restart php-fpm
Fix “Call to undefined function mb_strcut()” on Windows (using XAMPP or WAMP):
For XAMPP:
- Open the
php.ini
file located in thexampp/php/
directory. - Find the line
;extension=mbstring
, and remove the semicolon (;) at the beginning of the line to uncomment it. - Save the
php.ini
file and restart the Apache server using the XAMPP control panel.
For WAMP:
- Open the
php.ini
file located in thewamp/bin/php/php(version)/
directory. - Find the line ;extension=php_mbstring.dll, and remove the semicolon (;) at the beginning of the line to uncomment it.
- Save the
php.ini
file and restart the Apache server using the WAMP control panel.
After following the appropriate steps for your platform, the “Call to undefined function mb_strcut()” error should be resolved.
If it still persists, make sure that the extension=mbstring
line is not commented out in your php.ini
file and that the web server has been restarted.
Other cause of the error “Call to undefined function mb_strcut()” on Linux
Some server installations have multiple PHP versions installed, such as PHP 8.0 and PHP 8.1. Occasionally,
mbstring
may be installed on one version, perhaps PHP 8.1, while you PHP Laravel app is using php8.0.
To fix the problem in this situation, follow the installation instruction fo mbstring extension, but make sure to target the correct PHP version. Here’s an example for installing mbstring on Ubuntu for PHP 8.1:
sudo apt-get update
sudo apt-get install php8.1-mbstring
Don’t forget to restart the Apache or Nginx server after installation.
Comments