Fatal error: Call to undefined function mb_strtolower() even if mbstring is enabled

Fatal error: Call to undefined function mb_strtolower() even if mbstring is enabled

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Fatal error: Call to undefined function mb_strtolower() even if mbstring is enabled

The error message Fatal error: Call to undefined function mb_strtolower() usually screams one thing: you are trying to use a multi-byte safe string function in PHP without the mbstring extension loaded. However, there is a specific scenario where the extension appears present in your file listings or phpinfo() output, yet the function remains inaccessible at runtime. This happens when the PHP interpreter executing your application cannot find the compiled shared library.

This discrepancy often surfaces after an OS reload or a server migration. You might have restored your data and verified that the .so file exists in the expected location, but the dynamic linker cannot resolve it. In many Linux distributions, the default php-cli binary (used for command-line scripts) and the php-fpm or Apache modules often rely on different PHP builds configured at compile time. If your web server is running a version of PHP compiled against system libraries that differ from the one you think you are installing, you will see exactly this error.

Consider a scenario where you install the extension via the package manager:

sudo apt-get install php-mbstring

This command places the library file in /usr/lib/php/20210902/php_mbstring.so (the version number varies by distro). However, if your web server is configured to use a specific PHP binary located elsewhere—perhaps one you previously installed via PECL or compiled from source—the new system extension might not be visible to that specific binary.

To diagnose this, do not rely solely on phpinfo(). That output is generated by the CLI version of PHP unless you explicitly pass the -S flag to a web server or configure Apache to use the same executable. Instead, check which PHP binary your web server actually invokes. You can often find this path in the error logs or by examining the PHP_BINARY_PATH environment variable set in your web server configuration files (php.ini, .htaccess, or Nginx/Apache configs).

Run the following to see if the CLI and FPM versions match:

/usr/bin/php -m | grep mbstring
/usr/bin/php-fpm -m 2>/dev/null | grep mbstring # Adjust path based on your setup

If the first command lists mbstring but the second does not, you have a mismatched PHP environment. The solution involves ensuring the web server process loads the extension file explicitly in its own php.ini. Look for an extension_dir directive that points to the directory containing the .so files installed by your package manager. If the paths do not align, you may need to copy the compiled module to the directory expected by your specific PHP build or recompile PHP with the necessary flags to include the system libraries.

Another common pitfall involves version compatibility. Some extensions are compiled against a specific PHP API version. If your OS reload resulted in a newer PHP core but you installed an older pre-compiled extension package, the loader will fail silently until runtime, resulting in the "undefined function" error. Always verify that the extension file's internal magic number matches the PHP version it is intended for.

In frameworks like Laravel, this issue can be particularly insidious because the framework relies heavily on mb_strtolower() for slug generation and string manipulation. Even if your database migrations succeed, every request hitting a route with dynamic slugs will crash immediately. The fix requires aligning the build environments of your CLI tools, web server modules, and any containerized PHP processes to ensure they all reference the same shared library path.

If you are deploying via containers, ensure that php-mbstring is installed inside the image itself rather than relying on the host OS packages. A mismatch between the host's libraries and the container's isolated environment can lead to exactly this kind of runtime failure, regardless of how cleanly your code was restored.

Our network