Fatal error: Call to undefined function mb_substr() Error

While working on a PHP based website, I found this error: Fatal error: Call to undefined function mb_substr(). This error is caused because mbstring PHP module is not loaded at the PHP general configuration files. Let’s see how to fix it.

What causes Fatal error: Call to undefined function mb_substr() Error ?

This error happens beacuse mbstring module is missing at PHP server. mbstring module is not required on most PHP applications, however some apps who use the mb_substr() function will definetly need it.

How can I fix it?

It’s really simple, just install the mbstring php module.

If you have a cPanel based server

Use EasyApache to recompile Apache & PHP with mbstring support.

  • Login as root to WHM interface
  • On the left menu, select EasyApache
  • Click on Previously Saved Config
  • Click on Start Customizing based on profile
  • Select your Apache version (2.4 is recommended)
  • There may be alread selected options, leave it as they are (selected)
  • After Apache configuration is done, you will see PHP configuration stuff
  • It is recommended to keep the same PHP version
  • Click on Exhaustive Options Lists
  • It is recommended to keep all the already selected PHP modules
  • Just make sure you add the new required one: Mbstring
  • Once selected, move to the bottom and click on Save and finally Build.

Make sure you don’t close the window, as it may generate a corrupted compilation and your sites may stop working.

This will recompile Apache & PHP on your server. No downtime is expected on this manual builds, and if something happens, easyapache will probably restore a working backup made previous to the compiling process.

After the process is complete your Fatal error: Call to undefined function mb_substr() shouldn’t no longer exist.

If you have a plain CentOS based server

Just install the php-mbstring module using yum or dnf:

yum install php-mbstring

Apply the changes by restarting httpd server:

service httpd restart

That’s all, at this point either if you use cPanel or plain CentOS, your mbstring error should be gone.

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *