If you want to keep your website running smoothly and securely, it’s a good idea to change or update the server version of your PHP software, since PHP 7+ will soon be a minimum requirement for self-hosted WordPress. And, since PHP is the programming language that forms the backbone of WordPress, this is one tutorial you shouldn’t put off.
Table of Contents
So let’s get to it – why you need to upgrade, the possible drawbacks, and how to actually upgrade your server to PHP 8.
Why You Should Upgrade WordPress to PHP 8
If you’re running a WordPress site on your server, then you obviously have PHP already installed. So why bother upgrading when everything seems to be running fine?
Here are some of the most common reasons why you should update the version of PHP on your server:
- PHP 7+ is starting to be a minimum requirement for some WordPress plugins
- PHP 7+ will be a minimum requirement for WordPress core
- PHP 8 fixes countless security holes in older versions
- PHP 8 is up to 6 times faster than 5.x
These are all valid reasons, but before you go ahead and update PHP, there are drawbacks to upgrading that you should carefully consider and plan for.
Possible Side Effects
When you make the switch, it’s not all sunshine, lollipops and rainbows, unfortunately.
The main thing you need to keep in mind before you upgrade is that not all your plugins, themes, and scripts are necessarily compatible with the latest or specific version of PHP you want to use. If there’s an issue here, it could partially or completely break your site.
Each version of PHP brings on some variation of improvements, and possible fixes, security patches and structures to code. While some updates are less comprehensive than others, many versions include improvements or changes that make certain parts of older versions obsolete.
If you use plugins, themes, or scripts on your site that rely on outdated PHP code, and you upgrade to a newer version of PHP, the changes from the upgrade would cause old code on your site to be incompatible and break.
While this may not always happen, it’s important to review the changes you can expect to see in the version of PHP you want to use before you complete the upgrade. That way, you can review your site for code that wouldn’t be compatible, so you can modify it to work.
Besides manually checking your site for possible pain points, there may be plugins available to automatically do a scan of your site to determine whether your site would be compatible if you upgrade.
When you upgrade to PHP 8, the areas which are most susceptible to breaking are:
- Pretty permalinks and rewrite rules
- Regular expressions
- Classes initialization
- String matching
- Array parsing and indexing
- …and more
Checking PHP Compatibility
Here are some plugins you may find helpful in your quest for PHP compatibility:
- PHP Compatibility Checker – The WP Engine PHP Compatibility Checker can be used by any WordPress website on any web host to check PHP version compatibility. This plugin will lint theme and plugin code inside your WordPress file system and give you back a report of compatibility issues for you to fix.
- Query Monitor – Query Monitor is a debugging plugin for anyone developing with WordPress. It has some advanced features not available in other debugging plugins, including debugging of AJAX calls, REST API requests, redirects, and the ability to narrow down its output by plugin or theme.
- Debug Bar – Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
You can also enable error logging manually by using WP_DEBUG
. Read about debugging WordPress: How to Use WP_DEBUG and remember not to use this on a production site.
You can also see what has changed for each version of PHP before you upgrade:
- Migrating from PHP 5.6.x to PHP 7.0.x
- Migrating from PHP 7.0.x to PHP 7.1.x
- Migrating from PHP 7.1.x to PHP 7.2.x
- Migrating from PHP 7.2.x to PHP 7.3.x
- Migrating from PHP 7.3.x to PHP 7.4.x
If you find that you’re using a plugin, theme, or script that isn’t compatible with the version of PHP you need, you can contact the author or a developer to help resolve the issue.