How to change PHP version in WordPress. Should you use PHP 8?

PHP is essential to WordPress and it is what powers your website. It is the engine if you like. Wouldn’t you like a more powerful engine? Here’s how to upgrade PHP, but don’t go too far.

You may have heard that your website uses PHP and it is a scripting language, a sort of programming language that can perform a wide range of functions. It can be embedded into HTML files, so page.html could have PHP code within it. However, you can have files that are pure PHP without the need for any HTML. They often output HTML though.

Web browsers never see any PHP code and it never reaches your computer or phone because it is a set of instructions purely for web servers. What you see in a web browser is the result of a web server executing PHP code. The result is usually a web page. PHP can output a whole web page or parts of it.

Let’s not get too deep into what PHP is or how it works because most people do not need to know. Just think of it as the engine that powers your blog or website.

Which version of PHP should you use?

There are many versions of PHP and it is under constant development. The developers regularly add new features, speed it up, remove old features, fix security problems and so on. Version 8 of PHP is currently available, but many older versions are still in use, like 5.6, 7.0, 7.1, 7.2, 7.3, and 7.4.

The version numbers jump around a little and there was no PHP 6. At least not in use anywhere.

Which version should you use? The most recent version that works with your site.

Don’t they all work? Probably not. The problem is compatibility and the version of WordPress, theme, page builder, or plugins may or may not be compatible.

Sometimes functions are removed from PHP when a new version is released and this could be because they were buggy, used outdated methods, were slow, limited or had security flaws. If a plugin, theme or something else in your website or blog relies on a function that is removed from PHP, the site will malfunction. The problems caused range from a minor feature not working, which can be ignored, to bringing the whole site down, which obviously can’t.

There is no easy way to tell which version of PHP will work with your site. You could contact each plugin developer and theme developer and ask, but even then you may not find out.

The only way to tell if your site can be updated to use a better, faster, more secure and more modern PHP is to try it and see. Trial and error!

Fortunately, changing PHP version is as simple as selecting the version you want from a menu. You can upgrade and downgrade as often as you want with no problems. It sort of flicks a switch on the server to use whatever version you select.

Do not select the latest version of PHP 8 because it will probably cause problems with your website. It takes time for theme and plugin developers to update their code to use the latest version. They will get around to it eventually, but you must wait.

The best PHP version is usually the release before last. The previous version. Right now, PHP 8 is the latest and greatest (maybe 8.x if you are reading this in six months’ time), but it is probably the least compatible with your site. The previous version, currently PHP 7.4, is much more likely to be compatible with your website or blog.

If you have plugins or themes that have not been updated for a very long time, it is possible that they will fail with any recent version of PHP, which is why versions as far back as 5.6 are available.

I recommend trying 7.4 and if your site does not work, try successively older versions like 7.3, 7.2, 7.1 until you find the most recent version that your site works with. Alternatively, if you are on an old version of PHP, update to the next version until problems are found, then go back down to the last one that worked.

Update PHP to a newer version

A web hosting company will not change the PHP version your site uses because of potential compatibility problems. It leaves it alone. For this reason, sooner or later your site will be running an out-of-date version of PHP. Probably the version set when you first got the hosting. Updating PHP is entirely up to you.

How do you update PHP? This is not a WordPress feature and it cannot be done from inside WordPress. It is a web hosting configuration setting, therefore you must login to your web hosting account.

Different web hosts provide different menu systems, so it is not possible to give you exact instructions as to how to set the PHP version. Here is Bluehost.

Bluehost PHP settings

Bluehost cpanel web hosting menu

Login to your Bluehost web hosting account (not WordPress). In the menu at the top, click cpanel.

Bluehost cpanel web hosting menu

Scroll down the page until you come to the programming section and click the PHP Config icon. This is where you can select the PHP version.

Bluehost cpanel web hosting menu

There are currently versions 7.0 to 7.4 and a very old 5.6. At this point in time, PHP 8 is not an option. It is too new, but sooner or later it will be added to the list. PHP 7.2 and older is not recommended and your site should work fine on 7.4. If not, come back here and select, 7.3.

As you can see, it is very easy to select the PHP version in your hosting account. Let’s look at a different hosting account.

Ionos PHP settings

Ionos web hosting menu

Ionos web hosting menus are completely different to Bluehost and maybe your own hosting is different to them both. Hopefully, these two examples will help. At the Ionos site, click the Hosting tile.

Ionos web hosting menu with settings

On the next page is a number of tiles and among them is a PHP tile. Click the Open button to see the PHP settings.

Ionos web hosting menu

Your website is listed here and you can see the PHP version. Click the version number. It is a link that takes you to a new page where PHP versions are listed.

Ionos web hosting menu PHP settings

There are versions from 8.0 going down to 5.6, but anything older than 7.3 is not recommended. Just select the version you want, such as 7.4 and click the Save button at the bottom of the page.

Changing PHP version is basically just a matter of finding the right menu option and selecting it.

Before you navigate away from the PHP selection page, open your website or blog in another browser tab and make sure everything is working. Try the home page, some posts, menus and so on. Give it a good test and if something is not right, select the next oldest PHP version.

Related articles:

Leave a Reply