Switching to PHP 8.1 gives fatal error

Yesterday I switched my site from PHP 7.4 to 8.1 in cPanel’s MultiPHP Manager. It immediately started giving 500 Internal Server Error, and the message below in the debug log:

[31-Jan-2023 10:43:39 Europe/Budapest] PHP Fatal error:  Uncaught Error: Call to undefined function trailingslashit() in /home/aszex477/public_html/wp-includes/class-wp-textdomain-registry.php:103
Stack trace:
#0 /home/aszex477/public_html/wp-includes/l10n.php(784): WP_Textdomain_Registry->set('default', 'hu_HU', '/home/aszex477/...')
#1 /home/aszex477/public_html/wp-includes/load.php(1401): load_textdomain('default', '/home/aszex477/...', 'hu_HU')
#2 /home/aszex477/public_html/wp-includes/load.php(162): wp_load_translations_early()
#3 /home/aszex477/public_html/wp-settings.php(37): wp_check_php_mysql_versions()
#4 /home/aszex477/public_html/wp-config.php(88): require_once('/home/aszex477/...')
#5 /home/aszex477/public_html/wp-load.php(50): require_once('/home/aszex477/...')
#6 /home/aszex477/public_html/wp-blog-header.php(13): require_once('/home/aszex477/...')
#7 /home/aszex477/public_html/index.php(17): require('/home/aszex477/...')
#8 {main}
  thrown in /home/aszex477/public_html/wp-includes/class-wp-textdomain-registry.php on line 103 

I tried switching the site back to PHP 7.4, but it still throws the same error.

I don’t really know PHP, but after some googling I came across this Stack Overflow thread where I tried the linked answer. That removed the white screen and made the site display an error message that it needs MySQL installed (even though it already is). That didn’t seem like an improvement, so I switched that line in class-wp-textdomain-registry.php back to what it was.

Could you help me resolve this error? I don’t mind staying on PHP 7.4, the only reason I tried upgrading was because WordPress kept telling me that it was deprecated 😐

The page I need help with: [log in to see the link]


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer