Table of Contents
Last update on
Do you want to know how to check and update your PHP version on WordPress easily? It’s a wise decision to secure your site and ensure performance. PHP is the backbone of WordPress; it’s the language in which WordPress is primarily built.
Thanks to PHP, WordPress allows you to create advanced websites with complex features without knowing how to code. For example, PHP powers dynamic elements like contact forms or e-commerce functionalities.
Here’s what you will learn in this article:
- How to quickly check which PHP version your site is currently using.
- How to update PHP in a few steps.
- The importance of using an up-to-date PHP version.
- How to optimize your code (CSS and JavaScript) to improve performance even more.
Why Updating Your WordPress PHP Version Is Crucial
PHP has come a long way since its creation in the 1990s, and if you compare the very first version, PHP 1.0, to PHP 8.3 (the latest version), it shows how much the language has evolved around those three main points:
- Faster performance. Newer PHP versions make your site load faster.
- Better features and bug fixes to ensure compatibility with the latest WordPress functionalities and plugins.
- Stronger security updates.
💡Which PHP version should you use on WordPress? When writing this article (December 2024), WordPress recommends using at least the PHP 7.4 version to ensure high performance, security, and compatibility. |
Let’s go quickly over each benefit.
1. Recent PHP Versions Deliver Faster Performance
The latest PHP versions are developed with efficiency in mind to make your WordPress site load faster. So, if you use WordPress’s recommended PHP version (currently 7.4 or higher), your site will deliver superior performance and benefit all visitors. In short, a faster code is a good starting point for a faster site!
Going Beyond PHP and Optimizing Your Entire Code on WordPress
Running an up-to-date PHP version is excellent for performance, but WordPress is not only “made” of PHP. It also uses CSS and JavaScript, and we recommend optimizing those scripts on your site to improve its speed.
For example, you can minify CSS and JavaScript to remove unnecessary code that can bloat your files. You can also load your JavaScript after rendering the main content. The goal is to prioritize the visual content that needs to be rendered first to the visitor instead of the “complex backend” code.
🚀 Performance hack
You can implement those optimization techniques manually or use a plugin like WP Rocket to do the job for you!
WP Rocket can help optimize WordPress sites’ performance easily. Upon activation, it activates 80% of the performance best practices, such as caching or GZIP compression. Then, you can decide to optimize your code with a few clicks from the intuitive WordPress dashboard, helping you save time and effort:
2. Latest PHP Versions Ensure Better Compatibility With the WordPress Ecosystem
It is imperative to use one of the most recent PHP versions to ensure compatibility with WordPress themes and plugins. Authors and developers have designed tools to operate with the most recent PHP features and functions. If your site runs on an old PHP version, themes and plugins may crash or malfunction due to an inability to handle more recent coding standards.
🧩 Compatibility hack #1: To run WordPress efficiently and ensure compatibility with the most popular themes and plugins, check that your site supports the following technical requirements:
- PHP version 7.4 or greater.
- MySQL version 8.0 or greater (ask your host).
- MariaDB version 10.5 or greater (ask your host).
🧩 Compatibility hack #2: Before installing a new plugin, check which PHP version you should have before downloading it.
For example, Imagify’s team says you should use a PHP version of 7.3 or higher to use the plugin without any PHP conflicts.
3. Up-to-Date PHP Provides Improved Security
Did you know that PHP is used by 75.4% of all websites? It makes it the #1 framework used on the back end. Unfortunately, this also makes it one of the most targeted for hackers. Outdated PHP versions no longer receive security updates or patches, and hackers can exploit those “backdoors,” gain unauthorized access, and compromise your WordPress site.
Using a recent version of PHP is a very good start for security, but it’s not enough to ensure optimal protection for your WordPress site.
🚧 Security hack: Use a WordPress plugin like WordFence or Sucuri plugins to protect your WordPress site from malware and malicious attacks. You can also implement our 16 WordPress security best practices to ensure a fully protected site.
3 Ways to Check PHP Version in WordPress
Running a WordPress PHP version check on your site is a good idea to ensure you use the most up-to-date version. There are 3 easy ways to determine which PHP version is your WordPress site running on: check directly from your WordPress dashboard, access it via your hosting provider’s cPanel, or create a separate PHP info file.
1. Checking PHP Version From Your WordPress Admin (The Easy Way)
The easiest way to check which PHP version you use is to log into your WordPress admin. Go to Tools > Site Health > Info > Server, and check the PHP version’s row.
2. Checking PHP Version From Your Hosting cPanel
Another way to check the PHP version you currently use on WordPress is to ask your host or log on to your cPanel. From there, you can easily manage your domain database and see which PHP version you use.
Another way to check the PHP version you currently use on WordPress is to ask your host or log on to your cPanel. From there, you can easily manage your domain database and see which PHP version you use.
- Connect to your cPanel using your username and password.
2. Then scroll to the Software submenu and click the Select PHP Version button.
3. You’ll see the current version of PHP used by your WordPress site.
3. Create and Upload a New PHP File to Your WordPress Site’s Root Directory
You can create a new PHP info file to check the PHP version your WordPress site is using. This method is more complex than the previous ones, as you’ll need to create your PHP info file and upload it to a directory.
Important: Use this method only if you’re comfortable working with code.
- Create a PHP info file (e.g., phpfileinfo.php).
- Save it in the following directory.
/home/customer/www/yourwordpresssite.com/public_html - Add the following code snippet to the file.
<?php phpfileinfo(); ?> - Use the following URL to access the file through a web browser like Chrome or Safari.: http://yourwordpresssite.com/phpinfo.php
- Your site’s PHP version will be displayed on the page.
How to Update Your WordPress PHP Version
Now that you’ve checked your PHP version and know which version your site is running on, it may be time for an update. The easiest way to update your PHP version on WordPress is to use your hosting cPanel. You can also ask your host to do it for you.
- Go to your hosting cPanel and head to the Software subsection.
- Click on the Select PHP Version button.
3. Choose the PHP version you want to use on your site from the drop-down menu.
9 Best Practices for Updating PHP Version in WordPress
While it’s essential to update and run on one of the latest PHP versions for optimal performance and security, remember not to rush the process. Take your time and follow our 9 best practices to prepare your WordPress site’s PHP update properly.
- Determine if an update is urgent. If your PHP version is below 7.4, it’s time to upgrade.
🚧 Safety PHP upgrading tip if you are using a very old PHP version (under 7): We recommend creating a staging site and running the PHP update there before doing it on the production (live) site. Working on a staging site first allows you to test the PHP update in a safe environment and identify any issues that could occur on your live site. |
- Create a complete backup of your website.
- Contact the authors of your theme and plugins to check for any known issues with specific PHP versions.
- Scan your site using a plugin like the Plugin Compatibility Checker to check if your plugins are compatible (or not) with the PHP version you plan to upgrade to. From the plugin interface, you can see the supported PHP version for each plugin and see if it’s “updateable” with the latest WordPress version.
- Based on the results, update WordPress, plugins, and themes as needed.
- Finally, update your PHP version.
- Monitor and check that the new version is up and running from the health tool section in WordPress admin.
- Browse your site and test the functionalities to ensure it works properly without errors or bugs. For example, open several pages, test the contact form, and see if all the designs display well.
- Go to PageSpeed Insights or GTmetrix to check for any performance gain, especially if you updated your site to PHP 8+, which guarantees an instant speed boost.
Troubleshooting Common Issues After PHP Update
Updating PHP is usually safe, but you might encounter errors and bugs related to deprecated functions. Here’s how to resolve issues on your website caused by the latest PHP update.
Step 1: Roll back to the previous PHP version.
Step 2: Update WordPress, your theme, and plugins.
Once you’re logged in, click Updates in the left menu. If you see a red dot with a number, it means updates are available.
Step 3: Now that the WordPress core, all plugins, and themes are up-to-date, update your PHP again.
What should you do if that still does not work?
Strategy #1: Restore an older backup version of your site from your host panel.
Strategy #2: Enable PHP error reports and share them with your hosting provider or developers. Add the following code lines to your PHP code file to enable PHP:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Some hosts let you activate PHP reporting directly from the cPanel dashboard.
Wrapping Up
Now you know why upgrading PHP is so important: it improves speed and security and ensures compatibility with the WordPress ecosystem. But before diving in, follow our 9 best practices to prepare for a smooth update with your host.
Upgrading to PHP 8 or higher will give your site a performance boost, but don’t stop there – optimize your entire site with WP Rocket! This plugin makes it easy to optimize CSS and JavaScript with just a few clicks, helping your site run even faster. Upon activation, caching, GZIP compression, and many other performance techniques are also implemented.
Ready to improve your site’s performance? Update your PHP and try WP Rocket today – it’s risk-free and has a 14-day money-back guarantee!