Set your site to use newest PHP version

The latest available PHP version: 7.4

Additional information on our blog: https://seravo.com/blog/php-7-4-released

---

In this guide you learn, how you can transfer your site to using the newest PHP version. PHP is a server-side scripting language, that is most often used in web development. The WordPress core and most WordPress plugins and themes are written in PHP.

If wp-php-compatibility-check returns errors, you can’t do a version update before the errors have been fixed. Seravo’s plans do not include fixing a plugin or theme to work with the newest PHP version. Seravo only updates the plugin or theme to the newest version and it is generally on the plugin developers responsibility to maintain the plugin. But if you can’t fix the errors yourself, you can contact our customer support for recommendations on digital agencies or freelancers whom you could buy the necessary work to upgrade or fix the plugins you need.

Why change to the newest PHP version?

PHP updates usually include several security and performance related improvements. It is therefore recommended to change to the newest PHP version as soon as it's possible. Learn more on the WordPress Support site.

A major change in PHP versions occurred in late 2018, when security support for the widely used 5.6 ended.

Seravo's latest blog posts on the subject can be found on our website with the keyword "PHP". We always blog about all the most relevant changes so you don’t have to figure them out yourself.

How to change the PHP version?

From the WordPress admin panel

By logging to the admin panel of your WordPress site and going to the Upkeep page under the Tools menu, you get to change the PHP version of your site to your liking. The same tool also shows the current PHP version used.

From the command line

You can also use the command wp-check-php-version over SSH to display the current PHP version in use. If you use an older PHP version, the command will return a warning of the versions security has ended.

With a recent PHP version in use, command output will look like this:

Checking for PHP backends...
Found PHP mode definition: php7.4 in '/data/wordpress/nginx/php.conf'
Using php7.4
php7.4

With an older PHP in use, command output will look like this:

Checking for PHP backends...
Using default PHP mode (php5)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! WARNING: PHP 7.0 is deprecated, security support has ended 3rd December 2018! !
!                                                                               !
! See <https://seravo.com/docs/configuration/php7-hhvm/> for more details.      !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
php5

PHP version should be defined in /data/wordpress/nginx directory, where you should create a php.conf file and set in this file the following: “set $mode php7.4;”. The version number in the command must be changed to the desired one.  After that you must restart the Nginx by running wp-restart-nginx, because the nginx needs to restart to the new PHP version configuration can take place. Learn more on our documentation for developers.

With the command below, you can choose to do all of the above at once:

echo "set \$mode php7.4;" | tee /data/wordpress/nginx/php.conf && wp-restart-nginx

After the change, it's good to check the error logs of the site to make sure the change didn’t trigger any errors. Log file can be found from under the /data/log directory. You can also check this directly from the WordPress admin panel.

How to check if plugins are compatible with the newest PHP?

From the WordPress admin panel

Compatibility checking is done with the same tool you use to change the PHP version. Log in to the WordPress admin and open the Upkeep section under the Tools menu, where you will find the Seravo-plugin tool.

From the command line

Site's plugins compatibility with the newest PHP can be checked with wp-php-compatibility-check, that’ll reveal PHP code incompatibilities and give you some details, why the plugin in question isn’t compatible.

The test results are logged in the file /data/log/wp-php-compatibility.log and inside the log file you will find warnings like the one below for some of the plugins you are using:

FILE: /data/wordpress/htdocs/wp-content/plugins/stackable-ultimate-gutenberg-blocks/freemius/includes/class-freemius.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------
 18305 | WARNING | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as
       |         | passed to a parameter, but will instead provide the current value. The parameter "$tag" was used, and possibly
       |         | changed (by reference), on line 18303.
 18462 | WARNING | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as
       |         | passed to a parameter, but will instead provide the current value. The parameter "$tag" was used, and possibly
       |         | changed (by reference), on line 18460.
----------------------------------------------------------------------------------------------------------------------------------

You can use the wp-php-compatibility-check command to check the compatibility of an individual theme with the latest version of PHP:

$ wp-php-compatibility-check /data/wordpress/htdocs/wp-content/themes/twentytwenty
.............................. 30 / 30 (100%)

Time: 529ms; Memory: 14MB

Scan complete. Results are stored in the logfile /data/log/wp-php-compatibility.log

The command can also be used to check the compatibility of a specific plugin:

$ wp-php-compatibility-check /data/wordpress/htdocs/wp-content/plugins/autodescription
............................................................  60 / 114 (53%)
......................................................       114 / 114 (100%)

Time: 3.86 secs; Memory: 18MB

Scan complete. Results are stored in the logfile /data/log/wp-php-compatibility.log

Additionally, you can view compatibility for a specific version of PHP by adding the version number to the end of the command:

$ wp-php-compatibility-check /data/wordpress/htdocs/wp-content/themes/twentytwenty 7.4
.............................. 30 / 30 (100%)

Time: 530ms; Memory: 14MB

Scan complete. Results are stored in the logfile /data/log/wp-php-compatibility.log

More information on the version change

5.6.x -> 7.0.x

7.0.x -> 7.1.x

7.1.x -> 7.2.x

7.3.x -> 7.4.x

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us