For optimal functionality and security, every WordPress admin needs to ensure that their theme, plugins, and WordPress core are running their latest versions. On top of this, you should also know how to update PHP in WordPress.

But hold on … what is PHP? The term might sound familiar, and that’s because your site, and all WordPress websites, run on it. PHP is a server-side scripting language that works with HTML, CSS, and JavaScript to create the framework of your WordPress site.

In this post, we'll cover:

Grow Your Business With HubSpot's Tools for WordPress Websites

What is PHP?

PHP is a programming language frequently used on the web. It is a server-side language, which means it runs on the server that hosts the website. PHP is also the programming language used to build and maintain WordPress.

What exactly does PHP do on the web server? In short, PHP is what generates dynamic web pages. Dynamic web pages are HTML files assembled by the hosting server when requested by a client, instead of being stored on the server in their entirety (as is the case with static websites).

When a visitor requests a web page with a URL, a special PHP module on the server processes the request, then executes PHP code to create an HTML page from scratch.Then, the server delivers a complete HTML file back to the visitor’s web browser.

The latest stable version of PHP is PHP 8, released in November 2020. It is a major upgrade from the previous version, PHP 7. PHP 8 came with numerous improvements and new features that make it more efficient and reliable.

What does PHP do in WordPress?

Rather than store each website page separately as individual HTML files, WordPress contains many PHP files that each control a different part of your page, such as headers and footers, comment sections, etc. If you look at your WordPress file names, you’ll notice these files end with a “.php” extension.

On a WordPress site, the main job of PHP is to fetch page content stored in your WordPress database and turn it into a web page. Upon receiving a request for a page, the PHP code pulls relevant content from your WordPress database, converts it into an HTML file, and sends the HTML back to the visitor who made the request.

Why assemble pages this way? In a word, flexibility. PHP makes it possible for developers to create themes and WordPress plugins that run on their own PHP files. These themes and plugins can use WordPress database content however they like. If you want to swap plugins and/or themes, this setup also lets you do so without the need to generate a new set of pages every time. Every page on your site is generated in real-time when requested.

Some WordPress websites may also implement a PHP framework for a more lightweight, efficient website.

Why You Should Upgrade PHP in WordPress

WordPress and many WordPress hosts make updates easy with automation. Still, manual updates can be a hassle. Is upgrading PHP really worth your time?

Absolutely. The benefits of the latest PHP can be narrowed down to three factors: speed, security, and compatibility.

Increased Speed

Between releases, PHP developers update the language to use resources more efficiently and introduce new features and functions. This means that each new release of PHP will run your WordPress website faster than before. Not only will better performance keep visitors engaged with your site — it can also improve your rankings in search engines.

For other ways to speed up your WordPress website, check out our tips to improve WordPress site performance.

Improved Security

PHP’s popularity makes it a common target for cyberattacks. To counter these attacks, new PHP releases contain patches to vulnerabilities exposed by hackers. If your WordPress site is running an old version of PHP, it won’t have these fixes in place and will be more susceptible to malware, viruses, and unwanted access to your site’s backend.

New PHP alone won’t keep intruders out. See our guide to WordPress security for steps on how to harden your WordPress site

Better Compatibility

WordPress websites are made up of multiple parts, and when one component upgrades, the rest tend to follow. The best WordPress themes and plugins, as well as WordPress itself, always run on the latest version of PHP. If you’re stuck on a previous version, the lack of compatibility between PHP and your core files, plugins, and theme might break your website.

As a WordPress administrator, you don’t need to know the nitty-gritty details about how PHP works. However, knowing how to update PHP is a must.

Let’s get started.

1. Check your current PHP version.

To make sure your system requires a PHP update, you can check in WordPress. From the administrator dashboard, select Tools > Site Health. In the Status tab under Site Health Status, WordPress will tell you if your version of PHP should be updated, along with other security and performance improvement recommendations.

the Site Health Status window in WordPress

2. Back up your website.

Most WordPress tutorials will advise you to back up your site before making significant changes, and updating PHP is no exception. The actual switch to PHP typically won’t bring up any show-stopping issues. But, just in case, it’s always ideal to have a failsafe copy on hand.

For help with this, see our guide to backing up your WordPress website.

3. Update your WordPress core, plugins, and active theme.

With a backup ready, you can begin preparing your website for the PHP update.

To prevent functionality issues stemming from poor compatibility with PHP, check that all your themes, plugins, and core files are running their latest versions. Quality plugins and themes should work with PHP 8 — if not, find one that does.

Check for any recommended updates under Dashboard > Updates, and click Update all if prompted.

the plugin update window in wordpress

4. Update your PHP version.

Now for the actual updating part. The module that processes PHP code is installed on your site’s web hosting server. When I say, “updating PHP version,” this module is what we’re actually changing. Because the inner workings of PHP are handled by your server, all PHP updates are done through your host.

There are two ways to update PHP on your host: contacting your hosting provider, or updating manually if possible.

Talk to Your Hosting Provider

The more hands-off approach is to reach out to your host directly via chat, email, or phone, and simply ask to update. In most cases, your provider will take care of this for you, or add an upgrade option to your hosting control panel along with instructions. In some cases, your host might offer an automated upgrading service.

Other providers may not support PHP 8 and have no plans to switch. In this case, consider switching to a new WordPress host. The benefits of PHP 8 outweigh the inconvenience of transferring hosts.

Update PHP Manually

If you’d rather try to make the update yourself, you’ll need access to a hosting control panel. While control panels differ across providers, one of the most common is cPanel.

To make the switch, navigate to the Software/Service tab and search for a PHP option. Then, click Select PHP Version. You’ll see this screen:

updating php in wordpress through the cpanel dashboard php version selector

The highlighted drop-down lets you set your current PHP version. As long as your hosting provider has done its job, some variant of PHP 8 should be available. Once you’ve selected version 8 from the drop-down menu, click Set as Current at the top or Save at the bottom.

This process will vary slightly between hosts. For example, here's a video tutorial explaining how to change your PHP settings with popular WordPress hosting provider Bluehost:

If you get stuck, check your provider’s documentation or help resources, and reach out to support if you need to.

5. Check your updated site.

Give your host at least 30 minutes for the PHP to fully update. Then, make sure your WordPress site still works by viewing all your pages and testing your plugins one-by-one.

If there’s a problem, you may be able to revert to your old PHP version in cPanel or by contacting your host again. If worse comes to worst, you have a backup standing by to reset your update.

And with that, you’re all set. PHP 8 will bring your site many benefits over previous iterations. Sit back and enjoy the increased performance, enhanced functionality, tighter security, and happier visitors.

Keep your site healthy by updating PHP.

It may seem trivial to newer site owners, but the quality of your back-end code has a big effect on your site’s user experience, especially when it comes to loading times, security, and compatibility with themes and plugins.

Running the latest version of PHP is an absolute must for any WordPress website, so don’t lag behind. You don’t even need to be a programming expert to follow the steps above to get your site up-to-date.

Editor's note: This post was originally published in December 2021 and has been updated for comprehensiveness.

Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

 Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

Originally published Jul 7, 2022 7:00:00 AM, updated July 07 2022

Topics:

WordPress Website