"Call to undefined function X()" in PHP — What It Means and How to Fix It

What the PHP error "Call to undefined function X()" means and how to fix it.

Published October 31, 2026

PHP cannot find a function with that name. It may be misspelt, defined in a file that was not included or part of an extension that is not installed.

What it means and why it happens

Typical causes: a missing extension (mbstring, curl, gd), a typo, a function removed in the current PHP version, or calling a namespaced function incorrectly.

Read the full message: it names the file and line where the problem was detected, which is the best place to start.

What you see

run the code
Fatal error: Uncaught Error: Call to undefined function mb_strlen()

Practical examples

Code that triggers it

<?php
echo mb_strlen('héllo');   // mbstring not enabled

The fix

<?php
// install/enable the extension, then restart PHP
// sudo apt install php8.3-mbstring
echo mb_strlen('héllo');

Check loaded extensions

php -m | grep -i mbstring
php --ini

Common mistakes

  • Different PHP versions for CLI and web.
  • Forgetting to restart PHP-FPM after enabling extensions.
  • Calling a function before its file is included.

Key takeaways

  • Call to undefined function: PHP cannot find a function with that name.
  • Read the message and the line number first.
  • Fix the cause, don't just silence the error.

FAQ

CLI works but the web fails?

They may use different php.ini files; compare phpinfo() for each.

How do I find which line caused Call to undefined function?

The error message and stack trace show the file and line; start there and work backwards.

More PHP articles