Every bit a WordPress administrator, updates are central to your job. For optimal functionality and strong security, you lot need to ensure that your theme, plugins, and WordPress cadre are running their latest versions.

On meridian of this, we likewise recommend updating your PHP.

But concord on...what is PHP? The term might sound familiar to you — that'south because your site, and all WordPress websites, run on it. As function of WordPress' underlying code backbone, PHP works with HTML, CSS, and JavaScript to create the framework of WordPress sites worldwide.

In this postal service, I'll encompass what y'all need to know about the PHP language, how it generates content in WordPress, why it needs to be updated, and how to upgrade your WordPress site to the latest version of PHP.

Grow Your Business With HubSpot's Tools for WordPress Websites

What is PHP?

PHP is a programming language frequently used on the web. First released in 1995 as a general-purpose programming language, PHP has become a favorite tool among developers for enabling dynamic spider web pages. Dynamic spider web pages are those which are generated by the hosting server when requested by a client, rather than stored on the server in their entirety.

PHP is a server-side language, which means it runs entirely on the server that hosts the website. This distinguishes it from other languages you might know, including HTML, CSS, and JavaScript. These are client-side languages — they run on the device of the visitor accessing a website (i.due east., the visitor'south web browser).

So, what exactly does PHP do on the web server? In short, PHP code is what generates the dynamic HTML pages to be sent to the customer. When a site visitor requests a web folio with a URL, a special PHP module on the server processes the request, then executes PHP code to create an HTML page from scratch. Lastly, the server delivers a complete HTML file back to the visitor'due south web browser.

What does PHP do in WordPress?

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

On your WordPress site, the primary job of PHP is to fetch page content stored in your WordPress database and turn it into web pages. Upon receiving a asking for a folio, the PHP code pulls relevant page content from your WordPress database, converts information technology into an HTML file (and accompanying CSS files), and sends the HTML back to the visitor who made the asking.

Why gather pages this way? In a word, flexibility. In conjunction with HTML and CSS, PHP makes information technology possible for developers to create themes and must-take WordPress plugins that run on their ain PHP files. These themes and plugins can apply WordPress database content however they similar. If you want to swap plugins and/or themes, this setup also lets you practice then without the demand to generate a new fix of pages every fourth dimension. Every folio on your site is generated in existent-time when requested.

Additionally, PHP is a skilful fit for WordPress because, like WordPress itself, PHP is open-source. Anyone can see how the language works under the hood and customize it for their site if desired.

PHP and the CMS Revolution

While PHP enjoyed some popularity in the web development customs for years, the advent of Content Management Systems (CMS) really put this language on the map. WordPress is the about popular CMS on the cyberspace, and this fact is a testament to the robustness and versatility of PHP.

What is PHP 7?

PHP 7 is the latest version of PHP, released in belatedly 2015. WordPress played a primal role in shaping this version — during its development, the WordPress community examined and tested every chemical element to ensure compatibility with the CMS.

Today, more 18% of WordPress sites apply PHP 7, with many plugins and themes actively supporting this version. PHP upgrades are ongoing, and PHP viii will be released in tardily 2020.

PHP 7 is a major upgrade from the previous version, PHP 5.6. (If you're wondering what happened to PHP 6, the project was scrapped due to technical issues and poor reception.) Notable improvements in PHP seven include:

  • Increased speed: PHP 7 uses less retentivity to accomplish the same goal, providing a substantial performance boost.
  • Enhanced declarations: The addition of Scalar Type and Return Type declarations makes lawmaking easier to read and customize.
  • Improved error handling: Previous PHP versions handled fatal errors past halting the entire code script. PHP 7 lets the script continue to run and throws an mistake instead.

Why You Should Upgrade Your PHP in WordPress

WordPress and many WordPress hosts make updates piece of cake with automation. Still, manual updates can exist a hassle. Is upgrading PHP really worth your time?

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

Increased Speed

Between releases, PHP developers update the language to use resources more than efficiently and innovate new features and functions. This means that each new release of PHP will run your WordPress website faster than before. Non only will amend functioning continue visitors engaged with your site — it can also boost your rankings in search engines.

To evaluate PHP 7 performance, we tested PHP 7 on WordPress in a strictly controlled environment. The server was hit 37,378 times with zero errors and zippo timeouts. The average response time was 4 milliseconds with caching:

a graph showing increased response times on a WordPress website using PHP 7

a chart showing increased hit rates on a WordPress website using PHP 7

Comparing these results with the previous version of PHP, we run across remarkable improvements in performance and average response fourth dimension. When we ran the same tests on PHP 5.five, the server was hitting 24,731 times with zippo errors and zero timeouts. Merely, the boilerplate response time was much slower at 208 milliseconds.

For even more ways to speed upwards 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 erstwhile version of PHP, it won't have these fixes in place and will be more than susceptible to malware, viruses, and unwanted access to your site's backend.

New PHP alone won't go on 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, also as WordPress itself, always run on the latest version of PHP. If you lot'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 virtually how PHP works. However, knowing how to update PHP is a must. Allow's get started.

1. Check your electric current PHP version.

To brand sure your arrangement requires a PHP update, yous tin can check in WordPress. From the administrator dashboard, select Tools > Site Health. Under Site Health Status, WordPress will tell yous if your version of PHP should be updated, along with other security and functioning improvement recommendations.

the Site Health Status window in WordPress

2. Cheque compatibility with the latest PHP version.

Earlier upgrading your WordPress Site to PHP 7, make sure it's compatible with new PHP. The easiest way to do this is by using the plugin PHP Compatibility Checker.

The PHP Compatibility Checker plugin for updating PHP in WordPRess

Simply install and run the plugin through WordPress to cheque your existing lawmaking. If the plugin finds any problems, you'll see a list of errors and warnings along with specific code details to help make key changes before upgrading.

3. Support your website.

Most WordPress tutorials will suggest you to create a backup of your site earlier making significant changes, and updating PHP is no exception. The actual switch to PHP typically won't bring up whatsoever testify-stopping issues. Only, but in instance, it's always platonic to have a failsafe fill-in handy.

4. Update your WordPress cadre, plugins, and agile theme.

With a backup on paw, yous can begin preparing your website for the update itself. To prevent functionality issues stemming from poor compatibility with PHP, check that all your add-ons and your core files are running their latest versions. Check this nether Dashboard > Updates and click Update all if prompted.

Any quality plugin and theme will piece of work with PHP 7 — if not, find a better option that does.

five. 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. Considering the inner-workings of PHP are handled by your server, any PHP updates are done through your host

There are two ways to update PHP on your host, by contacting your hosting provider, or by updating manually if possible. Hither I'll explain how to do both.

Talk to Your Hosting Provider

The more hands-off option for a PHP upgrade is reaching out to your host directly via conversation, e-mail, or telephone, and simply asking. In most cases, your provider will take care of this for you, or add an upgrade option to your hosting control panel forth with instructions.

In some cases, your host might offering an automating upgrading service. If and then, brand sure you've run compatibility tests and fixed any errors, since the hosting provider isn't responsible if something goes wrong with your site.

Other providers may non support PHP 7 and have no plans to switch. In this case, consider moving to a new WordPress host. The benefits of PHP seven outweigh the inconvenience of transferring domains.

Update PHP Manually

While hosting 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 selection. Then, click Select PHP Version. You lot'll see this screen:

the cpanel dashboard php version selector

The highlighted drop-down lets y'all ready your current PHP version. And so long as your hosting provider has done their task, some variant of PHP seven should exist available. In one case you lot've selected version 7 from the drop-downwardly menu, click Salve or Set as Current.

This process will vary slightly between hosts. If y'all go stuck, read over your provider'due south documentation or assist resources, and reach out to support if you need to.

6. Check your updated site.

Give your host at least 30 minutes for the PHP to fully update. Then, make certain your WordPress site still works by viewing all your pages and testing your plugins one-past-one. If there'south a problem, y'all may be able to revert to your quondam PHP version in cPanel or past contacting your host once again. If worse comes to worst, you have a backup continuing by to reset your update.

And with that, you're all gear up. PHP vii will bring your site many benefits over previous iterations. Sit dorsum and relish the increased performance, enhanced functionality, tighter security, and happier visitors.

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 Dec 1, 2021 12:23:00 PM, updated Dec 07 2021