WordPress will not work on PHP v8

With the release of PHP v8, we are aware of an issue with WordPress sites that make use this newer version.

All of our servers have certain PHP functions disabled as they pose a security issue in a shared hosting environment. One of these is a function called ini_set which is used to override PHP core settings. This function would allow a user to change security restrictions, allocate more memory to their hosting account, etc and so for that reason we obviously have this disabled.

PHP v8 has some changes in how it handles any functions that are specifically disabled. In PHP prior to v8, it would log an error in your PHP error log and still proceed with running the script, therefore a WordPress instruction to raise the memory limit would just be ignored and it would carry onto the next step. In PHP v8 however, disabling a function actually removes it from the function table so the command no longer exists, therefore if a script tries to use it then instead of producing an error because it is blocked, the script stops because the command does not exist any more.

There is however an easy workaround for this issue in WordPress by adding a small piece of code to your wp-config.php - we specifically use this file as this will not be overwritten by any future upgrades and it is always loaded by every part of the application as this file contains core configuration details for your site. What this code does is define a new command (function) called ini_set which actually does nothing. This means that when WordPress calls the command ini_set to try and raise the memory limit, it instead runs your new empty function and carries on.

The code you require is as follows:

 

#PHP8 fix for ini_set being disabled
function ini_set() {
return;
}

 

Just add the above to the bottom of your wp-config.php file, and your site should then correctly work with PHP v8. It should look like this at the bottom:

#PHP8 fix for ini_set being disabled
function ini_set() {
return;
}

 

NB: Our newer servers now have a workaround that does not require this customisation. We will happily migrate your account to a newer server on request - just open a support ticket requesting this.

  • ini_set, php8, wordpress
  • 6 Users Found This Useful
Was this answer helpful?

Related Articles

Joomla will not work on PHP v8

Joomla PHP Fix With the release of PHP v8, we are aware of an issue with Joomla sites that make...

Moving your WordPress website to another folder

One of the common issues we see when customers install WordPress via Softaculous is that they...