PHP

Call to undefined function (PHP)

PHP tried to call a function that doesn't exist at that point.

What it looks like

PHP Fatal error:  Uncaught Error: Call to undefined function mb_strlen() in /var/www/app/index.php:12

What does "Call to undefined function (PHP)" mean?

A fatal error: PHP stops the script at that line. The function name is the main clue — a built-in name such as mb_strlen, curl_init or imagecreatefrompng means an extension is missing; your own function name means a file was not loaded.

What causes "Call to undefined function (PHP)"?

  • A typo in the function name.
  • A required extension isn't installed/enabled (e.g. mbstring, curl).
  • A file/library wasn't included/autoloaded.

How do I confirm the cause?

  1. Search the PHP manual for the function name. If it belongs to an extension (mbstring, curl, gd, intl), that extension is not enabled.
  2. Run php -m, or check phpinfo() in the browser, to list enabled extensions — the command line and web server can use different php.ini files.
  3. For your own functions, check the file defining it is included or autoloaded before the call.

How do I fix "Call to undefined function (PHP)"?

  • Check the spelling.
  • Enable the needed PHP extension (php.ini) and restart.
  • Require/autoload the file that defines it (composer install).

How do I stop it happening again?

  • Declare required extensions in composer.json ("ext-mbstring": "*") so a missing one is caught at install time.
  • Keep development and production PHP versions and extensions the same.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors