“Call to undefined function” PHP error

What the undefined function error means, and how to tell whether the cause is a removed PHP function, a missing extension or missing code.

TroubleshootingIntermediate2 min readUpdated

Does this match what you’re seeing?

  • Fatal error: Uncaught Error: Call to undefined function
  • The error appeared after changing PHP version
  • An application reports a missing requirement

PHP was asked to run a function it doesn’t know. There are three possible reasons, and the function name tells you which.

1. The function was removed from PHP

Common after upgrading PHP:

FunctionRemoved inReplacement
mysql_connect(), mysql_query()PHP 7.0mysqli or PDO
each()PHP 8.0foreach
create_function()PHP 8.0Anonymous functions
money_format()PHP 8.0NumberFormatter

Fix: update the application or plugin. As a temporary measure, switch back to the PHP version it worked on. How to change the PHP version in DirectAdmin

2. An extension isn’t loaded

Functions prefixed by an extension name — mb_, imagecreate, intl, curl_, zip_ — need that extension.

Fix: check whether it’s loaded for your PHP version, and try another available version if not. PHP extensions: how to check what’s available

3. The code that defines it wasn’t loaded

The function belongs to the application itself or a library, but the file defining it wasn’t included — a failed upload, a missing vendor/ folder from Composer, or a plugin whose parent plugin is disabled.

Fix: re-upload the application’s files completely, including vendor/. Deploying a PHP application (Composer, Laravel and frameworks)

Not with Traxio yet? You can try this on a real server with our free PHP hosting trial: 30 days free with no card, then £0.99 a month.

Popular

Tip: press / to search from any pageSee all results