Call to undefined function 🐘 PHP

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.

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

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 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.