Table of contents

Are you wondering why it is good to upgrade your WordPress website to the latest version of PHP?

It is essential to do this to have high security and ensure that your site runs correctly and has the highest possible performance.

If your site remains with an old version of PHP for a long time, it may suffer because it will no longer run.

To be able to design dynamic websites in WordPress, the CMS uses the script language PHP. This is constantly being further developed and has now reached version 8.1. Of course, a request is advisable for website administrators, but is there something to be careful about? The following article gives you a detailed overview of the advantages of the new version and some tips on making the switch.

We want to guide you as best as possible, so we prepared an article on how to upgrade to the newest version of PHP in WordPress.

But let’s first see what this PHP is

what is php in wordpress

PHP is a coding language for web development. More than 70% of websites are made using PHP. In addition, WordPress is a content management system that runs on PHP. Thus, all themes, files, and plugins run using the PHP code in which the website is written.

Also, PHP is a recursive acronym for Hypertext Processor. It is a scripting language used in particular when creating dynamic HTML websites.

Most content management systems such as WordPress, Joomla, TYPO3, or shop systems such as Magento or Shopware use the popular programming language to display the corresponding web content in the browser.

Why is PHP important?

Many website developers use PHP – as an open-source server-side scripting language to develop complex and dynamic websites.

According to WordPress.org statistics, https://wordpress.org/about/stats/, more than 50% of websites run on version 7.4 of PHP. Usually, a PHP version has a life cycle of 1-2 with support regarding security and other possible problems.

In 2022, the latest version of PHP is 8.1

what is php 8 wordpress how to upgrade

The changes are mainly geared toward developers.

In the following list, you can see some examples of what’s new that came with PHP 8.0:

     Just-In-Time Compiler (JIT) – ensures better performance

     Union Types – enables the combination of different script types and thus reduces the susceptibility to errors in the code

     Named Arguments – optimizes the syntax of the code

     Weak Maps – allows for more efficient management of system resources

     Attributes – Metadata can be used to declare functions, classes, or parameters in code, making debugging easier.

Good reasons to upgrade to PHP 8

As PHP continues to evolve, developers are discontinuing support for older versions. However, security patches are regularly released for the current versions, intended to close the code’s weaknesses and security gaps.

If your WordPress website is running on an outdated PHP version, you will no longer receive patches, and security vulnerabilities will no longer be corrected. Hackers would then have an easier time entering your site and stealing data or taking over the site entirely.

Most hosting providers are aware of this danger, which is why they usually only offer the latest PHP versions. This forces you to act automatically and update your system because, at some point, your PHP version will no longer be available to you.

But there is also another reason for an update: WordPress developers, as well as plugin and theme authors, are also increasingly switching to PHP 8.

php upgrade for wordpress

They see the benefits of the new version and want to integrate it into their apps. The developers are giving WordPress users plenty of time to switch and continue to support multiple PHP versions. But sooner or later, a switch is inevitable.

There are some important benefits that you should consider when you want to use the latest version of PHP:

Speed: if you are updating your WordPress site to the latest version of PHP, you can see an increase in site speed up to four times. So this will also help with your SEO efforts, and it will give your users a better experience.

Compatibility with most of the plugins so that the website will be more functional and dynamic. Also, this feature will help developers to save money and time when they are building your website.

Security: your site will be more protected against hacks and vulnerabilities. So we recommend you use the latest version of PHP for a better secure website.

By examining a subset of the changes in PHP 8, we’ve already confirmed that this is likely to cause serious bugs on websites, the origin of which is unclear. Often the error appears in one place but is caused by a plugin or theme in another place, making troubleshooting difficult.

Before upgrading PHP to 8, check if your software is compatible with the new version. You can find out the details of the plugin in the WordPress repository, or you can ask the author directly. The same applies to the themes.

upgrade wordpress php version

How an old version of PHP can affect your WordPress site

This depends on how you created your website. If your site is built in HTML, such as with Website Builder, then updating PHP has no effect.

If your website is built with PHP and the code is compatible with the new PHP version, your website will perform the same or better. If you’re using a CMS like WordPress, you’ll likely see some performance improvements, provided you’ve updated WordPress to the latest version.

If you use code that is outdated and not supported in the newer version of PHP, then your site will give errors and may stop working completely. For example, if you haven’t updated your CMS to the latest version or if your website uses custom code for which an update is not available. In this case, you need to update the code to make it compatible.

Note: If you suspect that your site contains outdated code, it is very important that you take the time to update your site before older PHP versions are removed from our servers. It’s easier to fix things if your site is still working, and you can switch between older PHP versions.

PHP compatibility checker

You can use the WordPress PHP Compatibility Checker to check in advance whether your plugins are designed for PHP 8.

WordPress itself supports PHP 8 from version 5.6. However, the CMS itself is already available from version 6. If you are still using WordPress 5, you should urgently update to 6.0 or higher before updating the PHP version.

php compatibility checker wordpress

It is also advisable to update all plugins and themes. Your apps would then be up to date and configured to PHP 8 as best as possible.

Turn on debug log

The debug mode in WordPress quickly provides an overview of incompatible plugins and themes in the debug.log.

Paste the following code into the wp-config.php in the root directory of your installation. Log files can then be accessed under /wp-content/debug.log.

This is possible by inserting the following code in the .htaccess on Apache web servers:

<Files “debug.log”>

   Require all denied

</Files>

Or for NGINX web servers in the NGINX Config:

location ~* /debug\.log$

{

    deny all;

}

Check on a test system.

Before you update your live site, make a copy on a local server or test domain. There you can test how your site works after the update without it affecting your live site.

You can easily set up a local server based on the Apache HTTP web server using XAMPP, LocalWp, Vagrant, or Docker.

WordPress backup plugins like UpdraftPlus or Duplicator allow you to quickly migrate your website to the local server, where you can test it extensively in the new PHP environment.

php wordpress upgrade

These tests are important because they are the only way to find out if your website is fully compatible with PHP 8. Otherwise, the code could break, and, in the worst case, your web project could fail completely.

We would recommend the following procedure:

    Set up a local installation

    Mirror page to local

    Disable all plugins

    Switch to PHP 8

    Turn on PHP Log and Debug Log

Test plugin by plugin:

    Activate it

    If necessary, test the functions of the plugin

    View frontend and backend

    Check logs

    Deactivate the plugin and test the next plugin

For developers: check code for compatibility.

To analyze code for compatibility with higher and lower PHP versions, this PHP Compatibility Checker on GitHub is certainly helpful.

Instructions in English would be, e.g.:

    http://peterfisher.me.uk/blog/how-to-check-if-your-code-is-compatible-with-php-8/

Switching to PHP 8 version in WordPress

Before you switch to PHP 8, create a backup of your website and secure it off-server. Should something go wrong, you’ll be back online quickly.

wordpress-backup-plugin

Suppose you have root rights on your server and also backup the server environment. If all backups are safe, you can start.

Log into your hosting provider’s control panel. Go to the menu item PHP Settings or Server Settings. Select version 8.0 or 8.1 there.

php upgrade wordpress cpanel

Now all your web applications, which you host on this special server environment, run on the new PHP version. Test your live site again. If you find any errors, you can revert to PHP 7.4 and investigate the bug in the test environment.

Conclusion

Now that you have all the information that you need in order to upgrade your WordPress site to the latest version of PHP, you can proceed with this process.

Good luck!

Feel free to check the rest of our articles on our blog or watch Kubio tutorials on Youtube.

Related articles

How to Create a WordPress Travel Website in 2022

wordpress media library