How to Update PHP in WordPress

Get HubSpot's WordPress Plugin
Jamie Juviler
Jamie Juviler

Published:

For optimal functionality and security, WordPress admins must ensure their theme, plugins, and WordPress core are running their latest versions. In addition, you should also know how to update PHP in WordPress.

person updating php in wordpress on a laptop

What, though, 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.

Grow Your Business With HubSpot's Tools for WordPress Websites

In this post, we'll cover the following:

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 entirely (as with static websites).

When a visitor requests a web page with a URL, a special PHP module on the server processes the request. Then, it 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.2.6, released in May 2023. It is a major upgrade from the previous version, PHP 8. PHP 8.1 has 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 control a different part of your page, such as headers and footers, comment sections, etc. If you look at your WordPress file names, 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 allows developers to create themes and WordPress plugins running on their own PHP files. These themes and plugins can use WordPress database content as they like.

If you want to swap plugins and/or themes, this setup lets you do so without generating a new set of pages every time. Instead, 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 Update PHP in WordPress

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

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

Increased Speed

PHP developers update the language between releases 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 for vulnerabilities exposed by hackers.

If your WordPress site runs an old version of PHP, it won’t have these fixes in place. As such, your website will be more susceptible to malware, viruses, and unwanted access to your site’s back end.

However, you need more than new PHP updates to keep intruders out. See our guide to WordPress security for steps on how to harden your WordPress site.

Better Compatibility

WordPress websites comprise multiple parts, and when one component upgrades, the rest tend to follow. The best WordPress themes and plugins and 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.

How to Check PHP Version in WordPress

It’s simple to check the PHP version your hosting provider uses.

To check, log in to your WordPress Admin dashboard and click on Tools > Site Health. Then, switch to the Info tab on this page.

Our example website runs an outdated version of PHP, and a prompt at the top indicates this.

How to check PHP version and update PHP in wordpress

As you can see, the website currently runs on version 7.0.33.

Another way to know the PHP version is to scroll down and click to expand the Server tab. This tab shows information, including the PHP version your hosting provider uses.

How to check PHP version through the server tab and update PHP in wordpress

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.

How to update PHP in Wordpress, the Site Health Status window in WordPress

2. Backup 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, having a failsafe copy on hand is always ideal.

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

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

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

To prevent functionality issues 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.1 — if not, find ones that do.

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

update PHP Wordpress, 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. So when I say “updating PHP version,” this module is what we’re changing. Because your server handles the inner workings of PHP, 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 contact your host directly via chat, email, or phone and ask for an 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.1 and have no plans to switch. In this case, consider switching to a new WordPress host. The benefits of PHP 8.1 outweigh the inconvenience of transferring hosts.

Update PHP Manually

If you’d instead like to 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.1 should be available. Once you’ve selected version 8.1 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 the popular WordPress hosting provider Bluehost:

If you get stuck, check your provider’s documentation or help resources, and contact support if needed.

5. Check your updated site.

Give your host at least 30 minutes for the PHP to update fully. Then, ensure your WordPress site works by viewing all your pages and testing your plugins individually.

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 to reset your update.

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

How to Check PHP Version in WordPress. Check your current PHP version. Backup your website. Update your WordPress core, plugins, and the active theme. Update your PHP version. Check your updated site.

What to Do After PHP Update

After the PHP update, check all parts of your website and ensure everything works. We strongly recommend updating your WordPress version to the latest release to get the best from the new PHP upgrade.

Essential elements like plugins and themes should also be running the latest versions. Lastly, we recommend that you completely backup your website.

What if the PHP update breaks my site?

It’s rare for a PHP update to break a WordPress website. However, issues could arise when the code running on your website uses old functions incompatible with the new PHP version.

So, the first thing to do is ensure that plugins or themes aren’t the problem. To determine whether this is the case, deactivate all your WordPress plugins and use a default WordPress theme.

If this doesn’t solve the problem, we strongly recommend contacting your hosting provider for assistance.

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 significant effect on your site’s user experience, especially regarding loading times, security, and compatibility with themes and plugins.

And the best part? You don’t need to be a programming expert to get your site running on the latest version of PHP.

Editor's note: This post was originally published in July 2022 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.

Related Articles

Capture, organize, and engage web visitors with free forms, live chat, CRM, analytics, and more.

DOWNLOAD THE FREE PLUGIN

CMS Hub is flexible for marketers, powerful for developers, and gives customers a personalized, secure experience

START FREE OR GET A DEMO