Ad Space — Top Banner

Fatal error: Call to undefined function

PHP Programming Language

Severity: Critical

What Does This Error Mean?

This error means PHP tried to call a function but could not find it anywhere. Either the function does not exist, it is defined in a file that was not included, or the function belongs to a PHP extension that is not installed. PHP stops running the script the moment it hits this error.

Affected Models

  • PHP 5.x
  • PHP 7.x
  • PHP 8.x
  • All PHP versions

Common Causes

  • The function name is misspelled — even one wrong character causes this error
  • The file that defines the function was not included or required before the call
  • The function belongs to a PHP extension (like GD, MySQL, or cURL) that is not enabled on the server
  • The function was defined inside a class and you are calling it without the class name
  • You are using a function that exists in a newer PHP version but your server runs an older one

How to Fix It

  1. Check the exact spelling of the function name. PHP function names are NOT case-sensitive, but a typo will still cause this error.

    For example, 'strtolower' and 'strtolower' are the same, but 'strtolowr' will fail.

  2. Make sure the file where the function is defined is included before you call it. Add require_once 'yourfile.php'; at the top.

    The order matters. Define or include the function BEFORE the line that calls it.

  3. Run phpinfo(); to check which extensions are enabled. Search the page for the extension you need (e.g. 'gd', 'curl', 'mysqli').

    If the extension is missing from phpinfo(), it needs to be enabled in php.ini or installed on the server.

  4. If the function is inside a class, call it correctly: ClassName::methodName() for static methods, or $object->methodName() for instances.

    Calling a class method like a plain function will always trigger this error.

  5. Check the PHP documentation to confirm the function exists in your PHP version. Some functions were added in PHP 8.0 or later.

    Visit php.net and search the function name. The page will show which PHP version introduced it.

When to Call a Professional

If the missing function belongs to a PHP extension and you cannot enable it yourself, contact your web host. Shared hosting providers can usually enable extensions like GD, intl, or zip on request. If you manage your own server, a sysadmin can help enable the right extensions.

Frequently Asked Questions

Does PHP function name capitalization matter?

For built-in PHP functions, no — 'strtolower' and 'STRTOLOWER' both work. But for functions you define yourself, some older PHP setups can be picky. The real risk is a typo — always double-check the spelling.

How do I check if a function exists before calling it?

Use function_exists('functionName') before calling it. This returns true if the function is available and false if it is not. You can then show a friendly error message instead of crashing.

What if the function exists but PHP still says it is undefined?

Check that the file containing the function is actually being loaded. Add a die('file loaded'); line at the top of that file to confirm. Also check for namespace issues — in modern PHP, functions inside a namespace must be called with the full namespace path.