This is a fatal error: execution stops at the line that called the function. The function name in the message is the key, because it tells you whether the problem is the server’s PHP setup, the PHP version, or your own code.
What the error means
PHP Fatal error: Uncaught Error: Call to undefined function mb_strlen() in /home/user/public_html/lib/Text.php:17
When PHP reaches mb_strlen(), it looks through built-in functions, functions from enabled extensions, and functions your code has defined so far. If it finds nothing, it stops.
Common causes
1. A PHP extension isn’t enabled. Many functions come from separate extensions:
| Function | Extension needed |
|---|---|
mb_strlen(), mb_substr() |
mbstring |
imagecreatefromjpeg(), imagecreatetruecolor() |
gd |
curl_init() |
curl |
bcadd(), bcmul() |
bcmath |
numfmt_create(), transliterator_transliterate() |
intl |
2. The function was removed from PHP. mysql_connect() and mysql_query() were removed in PHP 7.0; each() and create_function() in PHP 8.0.
3. Your own function wasn’t loaded: the file defining it was never required, isn’t registered with Composer, or the function lives in a namespace and was called by an incomplete name. If the message is about a class rather than a function, see Class not found.
4. In WordPress: calling a function from an inactive plugin, such as wc_get_product() with WooCommerce disabled, or using WordPress functions in a standalone file that never loaded wp-load.php.
How to fix it
- Copy the function name from the message; the full text is in cPanel under Metrics › Errors.
- If it’s from an extension: open Software › Select PHP Version, choose the version in use, tick the extension in the Extensions list (such as
mbstring,gdorintl) and save. Then confirm it’s loaded withphpinfo(), or over SSH:
php -m | grep -i intl
- If the function was removed: update the script or plugin to a version that supports PHP 8. For your own code, replace
mysql_*with PDO:
$pdo = new PDO('mysql:host=localhost;dbname=shop;charset=utf8mb4', 'shop_user', 'secret');
$stmt = $pdo->prepare('SELECT * FROM products WHERE id = ?');
$stmt->execute([$id]);
$product = $stmt->fetch(PDO::FETCH_ASSOC);
- If it’s your own function: make sure the file is loaded, ideally by registering it with Composer in
composer.json:
"autoload": {
"files": ["app/helpers.php"]
}
Then run composer dump-autoload. If the function sits in namespace App\Support;, import it where you use it: use function App\Support\format_price;.
5. In WordPress, guard the call:
if ( function_exists( 'wc_get_product' ) ) {
$product = wc_get_product( $id );
}
Prevention
- List required extensions in
composer.json, such as"ext-intl": "*", so Composer warns you at install time if one is missing. - Test on the same PHP version as the server before deploying.
- Read choosing a PHP version before upgrading, and search old code for removed functions.
On ArabyHost
Each site can run PHP 8.1, 8.2 or 8.3, with extensions toggled in Select PHP Version in cPanel, one click from the Araby Panel. PHP 7 isn’t offered, so code relying on mysql_* or each() has to be updated. On AI/Developer plans you have SSH and Composer to run composer dump-autoload directly; on other plans, run Composer on your computer and upload the vendor folder. The Araby AI assistant reads the error log and names the missing extension.
FAQ
How do I tell if the function comes from an extension or from my code?
Search for the function name in the official PHP manual. If it's documented there, it belongs to PHP or an extension, and its page names the extension. If not, it's defined in your project, a library or a WordPress plugin.
Can I run code that uses mysql_connect on PHP 8?
No. The mysql_* functions were removed in PHP 7.0 and no extension brings them back on PHP 8. Replace them with mysqli or PDO, or upgrade the script.
I enabled the extension but the error is still there. Why?
Make sure you enabled it for the PHP version the site actually uses, and that the command line uses the same version if the error comes from a cron job. Check phpinfo() or php -m to confirm it's loaded.