एरर समाधान · डेवलपर एरर

PHP "Call to undefined function": Missing Extension or Removed Function

Fix PHP's "Uncaught Error: Call to undefined function" by checking for a missing extension, a function removed in PHP 7 or 8, or a missing include.

Error messagePHP Fatal error: Uncaught Error: Call to undefined function mb_strlen()

लेखक: SiteDownCheck संपादकीय टीम · अपडेट: अक्टूबर 28, 2026 · 4 मिनट पढ़ने में

"Call to undefined function" means the code called a function name that PHP does not know at that moment. The function is not built in, not loaded from an extension, and not defined by any file that has been included so far. In PHP 7 and later it is thrown as an Error, so it appears as Uncaught Error; in PHP 5 it was a plain fatal error.

PHP Fatal error:  Uncaught Error: Call to undefined function mb_strlen() in /var/www/html/index.php:12
Stack trace:
#0 {main}
  thrown in /var/www/html/index.php on line 12

The function name in the message is your main clue. Which of the groups below it belongs to decides the fix.

Group 1: a PHP extension is not installed or not enabled

Many everyday functions live in extensions that are optional. Typical pairs:

  • mb_strlen, mb_substr: mbstring
  • curl_init: curl
  • imagecreatefromjpeg, imagecreatetruecolor: gd
  • simplexml_load_string: SimpleXML, dom for DOMDocument
  • mysqli_connect: mysqli; pg_connect: pgsql
  • iconv, bcadd, gmp_add, ctype_digit, json_encode (rare now): iconv, bcmath, gmp, ctype, json
  • idn_to_ascii, numfmt_create: intl

List what the web PHP actually has loaded:

php -m | sort
php -m | grep -i mbstring

Install the missing one. On Debian or Ubuntu the package name carries your PHP version, and you must restart the right service:

sudo apt install php8.2-mbstring php8.2-curl php8.2-gd php8.2-xml
sudo systemctl restart php8.2-fpm      # or: sudo systemctl restart apache2

On RHEL-style systems the names look like php-mbstring, and on shared hosting you enable extensions in the control panel's PHP selector.

Group 2: the function was removed in a newer PHP

Upgrading PHP breaks old code that used functions that no longer exist. Examples documented in the PHP migration guides:

  • PHP 7.0: the entire mysql_* extension (mysql_connect, mysql_query) and ereg* functions were removed.
  • PHP 8.0: create_function(), each() and money_format() were removed.

The error will name the removed function. Replace it (mysqli/PDO for mysql_*, anonymous functions for create_function, foreach for each), or update the plugin, theme or library that uses it. Check composer.json and your CMS's plugin list for versions that declare support for your PHP.

Group 3: your own function is not defined yet

If the missing name is one you wrote, check:

  1. The file is never included. Add the require or confirm the autoloader loads it. Note that Composer autoloads classes, not loose functions, unless the package lists the file under autoload.files.
  2. It is defined conditionally inside an if or another function, and the condition did not run.
  3. Namespace mismatch. Inside namespace App;, a call to helper() looks for App\helper first and falls back to the global function. If the function lives in another namespace, import it: use function Other\Space\helper;.
  4. A typo or case change in a method-like name. Function names are case-insensitive in PHP, but typos are not.
  5. A stale deploy: the new file with the function never reached the server, or OPcache serves the old version. Reload PHP-FPM or call opcache_reset().

Group 4: wrong PHP version for this site

A host that runs different PHP versions per site or per directory can serve your pages with an older build than you tested on. Check the version in use from the page, and compare the extensions of that exact build. In a container, make sure the image you run is the one you built.

Decision order

  1. Read the function name. Does it start with mb_, curl_, image, mysqli_, xml? Install the extension first.
  2. Does it look old (mysql_, ereg, each, create_function)? Fix code or update the package.
  3. Is it your function? Check includes, namespaces and deploy state.
  4. Still stuck? Confirm the web and CLI PHP are the same version.

अगले कदम

सामान्य प्रश्न

Why does the CLI work but the website fails?

They are usually different PHP installations with different ini files and extensions. Enable the extension for the PHP-FPM or Apache build that serves the site.

I installed the extension but nothing changed. Why?

The PHP process was not restarted, or you installed it for a different PHP version. Restart PHP-FPM or Apache and verify with phpinfo().

Can I fix this by adding a polyfill?

Sometimes. Packages like symfony/polyfill-mbstring provide pure-PHP fallbacks for some extension functions, which can unblock a restricted host, although they are slower.

Is this error a security problem?

No. It signals an environment or code mismatch, though a half-broken upgrade is worth checking right away.

Get notified when this fix updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.