Fixing “Call to undefined function”: the extension that is missing

The message “Call to undefined function name()” says the code called a function that the PHP of this folder does not have. Nearly always it is an extension that is switched off in this PHP version, and you switch it on in Select PHP Version. The start of the function’s name tells you which one.

It is not a function we “disabled”: no PHP function is disabled on this server (see exec and shell_exec). It is a function that was not loaded.

From the function to the extension

The function starts with… Extension to switch on
mb_ (mb_strlen, mb_substr) mbstring
curl_ curl
imagecreate…, imagejpeg… gd (or imagick, for the Imagick class)
bcadd, bcmul… bcmath
gmp_ gmp
pg_ (pg_connect) pgsql. PostgreSQL exists; the module ships switched off.
imap_, ldap_ imap, ldap
mysql_ (mysql_connect) None: these functions were removed in PHP 7. The code is old and has to move to mysqli or PDO. See connecting to MySQL from PHP.

The same goes for “Class not found”: Imagick, ZipArchive, SoapClient and Redis are classes that come from extensions (imagick, zip, soap, redis).

Fixing it, step by step

1 Note the function name and the file that calls it, both in the message.
2 Check which PHP version runs in that folder (see viewing and adjusting your PHP configuration). It is the most common reason for an extension being “on and not on”: you switched it on for one version and the site runs on another.
3 In Select PHP Version, pick that version, open Extensions and tick the extension from the table. See switching a PHP extension on.
4 Reload the page that gave the error. If it persists, check with a file containing <?php phpinfo(); that the extension shows as loaded.

Not sure which extension a function belongs to? Look its name up on php.net: each function’s page says which extension it belongs to and from which PHP version it exists. It is safer than switching extensions on blindly. And if the extension is not in the list for that PHP version, try another version; an application that demands an extension the account does not offer is a case for a VPS.

Changed the PHP version and the error only appeared now? Every version has its own set of enabled extensions. The ones you ticked on the old version do not carry over: tick them again. See changing your PHP version without breaking the site.
A missing extension can be code that is too old. If the function vanished from PHP itself (as with mysql_*, and each() and create_function() in PHP 8), no box brings it back. Update the application or, until you can, use an older PHP version for that folder only.

Switched the extension on and the function is still missing? Send us the message, the folder and the PHP version.

Open a support ticket

SEE ALSO

Switching a PHP extension on or off

Viewing and adjusting your PHP configuration

Do exec and shell_exec work here?

Where the PHP error log is

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.59/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?