Call to undefined function means PHP was asked to run a function it does not know. There are three usual causes: the extension that provides the function is not loaded, the function was removed in your PHP version, or the file that defines it was never included.
Before you start
- Copy the exact error from the log, including the function name.
- Know which PHP version the site uses. A
phpinfo()page or the control panel will show it.
Identify where the function comes from
| Function prefix | Extension to enable |
|---|---|
mysqli_* | mysqli |
curl_* | curl |
mb_* | mbstring |
imagecreate*, getimagesize on some formats | gd |
simplexml_*, dom_* | xml / dom |
zip_* | zip |
bcadd, bcmul | bcmath |
intl*, numfmt_* | intl |
sodium_* | sodium |
Enable the missing extension
- cPanel with CloudLinux: Software → Select PHP Version → Extensions, tick the extension and save.
- cPanel without CloudLinux: ask support, or on your own server use WHM → EasyApache 4.
- VPS: install the package, for example
sudo apt install php8.3-mbstring, then restart PHP-FPM.
Step-by-step instructions are in PHP extensions in cPanel and install PHP extensions on Linux.
Check the result from the command line with php -m | grep -i mbstring. The CLI and the web server can use different PHP versions, so check the website too.
Functions removed in newer PHP versions
| Old function | Removed in | Use instead |
|---|---|---|
mysql_connect, mysql_query | PHP 7.0 | mysqli_* or PDO |
ereg, split | PHP 7.0 | preg_match, preg_split |
create_function | PHP 8.0 | Anonymous functions |
each | PHP 8.0 | foreach |
money_format | PHP 8.0 | NumberFormatter (intl) |
utf8_encode, utf8_decode | Deprecated in 8.2 | mb_convert_encoding |
If old code calls these, update the plugin or script. As a short-term workaround only, run the site on an older supported PHP version. See the PHP version upgrade checklist.
Your own or a plugin's function is undefined
- The file that defines it is not included. Check the
require/includepaths and whether Composer'svendor/autoload.phpis loaded. - The function lives in a namespace. Call it as
\Vendor\Package\func()or adduse function Vendor\Package\func;. - The plugin that provides it is deactivated, while another plugin still calls it.
FAQ
The extension is enabled but the error remains. Why?
You probably enabled it for a different PHP version or handler than the one the site uses. Compare the version in phpinfo() on the website with the one you changed.
Why does it work in the browser but fail in cron?
Cron uses the CLI PHP, which may be a different version with other extensions. Call the full path of the right PHP binary in the cron command.
Is undefined method the same error?
Not quite. "Call to undefined method" means a class exists but lacks that method, usually because of a library version mismatch. Update the dependencies with Composer.
