Common causes
- The function was removed from PHP, such as mysql_* in PHP 7.0 or each() and create_function() in PHP 8.0
- A required extension is missing: mbstring, curl, gd, intl, zip or xml
- The file that defines the function was not included, or the Composer autoloader was not loaded
- A typo in the function name, or a namespaced function called without its namespace
- The function is defined conditionally or inside another function that has not run yet
- The host lists the function in disable_functions
How to fix it
- Identify where the function should come from. Search the PHP manual for the function name. If it belongs to an extension (curl_*, mb_*, image*, gd_*), it is an extension problem; if the manual says it was removed, the code needs updating; otherwise it should be defined in your project.
- Install the missing extension. On Debian/Ubuntu run sudo apt install php8.3-mbstring php8.3-curl php8.3-gd (matching your PHP version), then restart PHP-FPM or Apache. Confirm with php -m | grep -i curl, and check the web server's phpinfo() as well.
- Replace removed functions. Replace mysql_* with mysqli or PDO, each() with foreach, create_function() with an anonymous function, and money_format() with NumberFormatter. A plugin or theme that uses them needs an update or replacement.
- Load the defining file. Make sure require_once 'path/to/functions.php'; runs before the call, or that vendor/autoload.php is required. For Composer packages that ship functions, check the files section of the package's autoload config and run composer dump-autoload.
- Check namespaces and spelling. Inside a namespace, a function defined in another namespace must be imported with use function Vendor\Pkg\helper; or called by its full name. Also check disable_functions in phpinfo() if the name is correct.
Replacing removed mysql_* calls with PDO
// Old (removed in PHP 7.0)
// $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 stop it happening again
- Declare required extensions in composer.json, for example "ext-mbstring": "*"
- Scan code for deprecated and removed functions before upgrading PHP
- Keep development, staging and production on the same PHP version and extensions
- Use function_exists() checks only for genuinely optional features