Call to undefined function PHP Origin: Application & API Last updated 14 Oct 2026

PHP Fatal error: Uncaught Error: Call to undefined function

PHP can’t find the function you called — usually a missing extension, missing include, or namespace issue.

Exact message you may see Call to undefined functionUncaught Error: Call to undefined functionCall to undefined function mysqli_connectCall to undefined function curl_init
Seen on: PHP Linux

Meaning

If the function is built into a PHP extension (mysqli_connect, curl_init, mb_strlen, imagecreatefromjpeg), the extension isn’t installed/enabled for the PHP version actually running. Otherwise, the file defining it wasn’t loaded or the name/namespace is wrong.

Common causes

  • PHP extension not installed or not enabled (mysqli, curl, mbstring, gd, intl)
  • CLI and web server use different PHP versions/php.ini
  • File with the function not included / autoloaded
  • Function removed in newer PHP (e.g. mysql_connect removed in PHP 7, each() in PHP 8)
  • Calling a namespaced function without use function or full name

⚡ Quick fix

  1. Install/enable the extension: sudo apt install php8.2-curl (match your version) and restart FPM/Apache
  2. Check phpinfo() from the web server, not just php -m on CLI
  3. Replace removed functions (mysql_* → PDO/mysqli)
  4. Check includes/autoload and namespaces

Detailed fix by platform

PHP

  1. Find which extension is missing:
    bash
    php -v && php -m | grep -i -E 'curl|mysqli|mbstring|gd|intl'
    sudo apt install php8.2-curl php8.2-mbstring php8.2-mysql
    sudo systemctl restart php8.2-fpm

Code examples

Check whether an extension function exists at runtime

php
foreach (['curl_init', 'mb_strlen', 'mysqli_connect', 'imagecreatetruecolor', 'intl_get_error_code'] as $fn) {
    echo str_pad($fn, 24), function_exists($fn) ? "OK\n" : "MISSING\n";
}
echo 'php.ini: ', php_ini_loaded_file(), "\n";

Run it through the web server (not CLI) — CLI and FPM often load different php.ini files.

Replace removed mysql_* functions with PDO

php
// ❌ PHP 7+: Call to undefined function mysql_connect()
$link = mysql_connect('localhost', 'user', 'pass');

// ✅
$pdo = new PDO('mysql:host=localhost;dbname=app;charset=utf8mb4', 'user', 'pass', [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);

How to diagnose

  1. Function — Built-in (extension) or yours?
  2. Runtime — Which PHP version/ini does the web server use?
  3. Loading — Is the defining file included?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

42883 function — ERROR: function x(text) does not exist — No function matches the given name and argument types (PostgreSQL)42883 function500 — HTTP 500 Internal Server Error (HTTP)500ArgumentCountError — Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo(), 1 passed and exactly 2 expected (PHP)ArgumentCountErrorCall to member function on null — Fatal error: Uncaught Error: Call to a member function x() on null (PHP)Call to member functi…Call to undefined function (WordPress) — WordPress: Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() / add_action() / get_header() (WordPress)Call to undefined fun…Call to undefined function create_function() — WordPress on PHP 8: Fatal error: Uncaught Error: Call to undefined function create_function() / each() (WordPress)Call to undefined fun…Cannot redeclare — Fatal error: Cannot redeclare function foo() (previously declared in …) (PHP)Cannot redeclareCannot use object as array — Fatal error: Uncaught Error: Cannot use object of type stdClass as array (PHP)Cannot use object as …Call to u…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.