When a WordPress website is loaded, it runs on code. Once upon a time, that code was strictly HTML. Now, it’s a few different things, typically CSS, HTML and JavaScript.

That’s the front-of-the-house, though. The waitstaff that all visitors see. Back-of-the-house runs a bit differently; there are different cooks in the kitchen, and they influence a little bit of everything.

When it comes to WordPress, the programming language PHP is what’s really running the show. You’ll find PHP in everything from your WordPress dashboard (back end) to your website page templates (front end). PHP is also in your plugins, your theme… basically, your website doesn’t exist without it.

What is PHP?

PHP is an open source, free-to-use programming language, and because it’s so accessible, it’s one of the most-used programming languages in web development (Facebook uses it, too).

Here’s how the back-of-the-house impacts the front-of-the-house: PHP essentially takes information from your database, packages it as CSS and HTML, and then creates your gorgeous site for visitors to see.

PHP exists on the server end of things. To compare, something like JavaScript is processed on the client-side of the website, in the browser when someone visits your site. If a website problem is due to a PHP issue, you have to be the one to fix it (or your host does, at least) – even a super fast computer can’t quickly process PHP from a slow server.

The moral: PHP is pretty damn important, especially if you have a WordPress site – at least a WordPress site that you want to perform well.

PHP Requires Updates

Since PHP is central to WordPress, it’s always being tweaked and improved – there have been a lot of versions over the years. As of the writing of this article, you should have at least version 7.0, though 7.3 is the most recent version. By upgrading, you’ll access the newest PHP version, which also means the fastest, safest and just plain better version.

update PHP

Source: php.net

The biggest changes with PHP 7 are that it’s approximately twice as fast as the last version, PHP 5.6; code is easier to read and support; script problems are resolved smoothly; and its applications are more difficult to hack.

P.S. If you continue using an older PHP version, you won’t be able to access active support any longer, and security support will eventually run out, too. Translation: your website won’t be safe and you won’t be able to get any help with it should something go wrong.

Let’s Check Your WordPress PHP Version

Before you update your PHP, find out if you even need to by determining the PHP version you have right now. There are two simple ways to do this:

Check With Your Host

This is what I did. Actually, what I technically did was email DreamHost to say, “Umm, my website seems to hate me lately.” And they were like, “Yeah, it’s mad at you for having out-of-date PHP.”

If you can’t get a hold of your host’s customer service, you can probably check the version yourself. Look for something like “PHP Settings” or “PHP Version,” or “Manage Domains.”

In DreamHost, you can find out the version on the Manage Domains page.

update PHP

Use a PHP Version Plugin

You can use a plugin like Display PHP Version, which is possibly the easiest thing I’ve ever done when it comes to WordPress.

update PHP

You just install, activate and then see the version you’re using in the At a Glance section on the Dashboard:

update PHP

Is it Time to Upgrade Your PHP Version?

You found out the worst news possible and it’s time to upgrade your PHP. I’m going to assume your host will let you upgrade – if they don’t, it’s time to break up with them.

It’s always a little risky to upgrade because it’s possible that your website contains code that the new PHP version won’t be compatible with. If that happens, some or all of your website could behave strangely post-upgrade.

Let’s go over how to prevent that from happening.

You can do this on your live website, but an even safer solution is to make a local copy of your website and go through the process on that first as a test run.

Upgrade Everything (but Backup First)

Since PHP issues usually have to do with old code, it’s best to upgrade your plugins, theme and WordPress version before you do anything else. Also, you probably know this already, but you should always backup your site before updating anything.

update PHP

We’ve written a lot about backing up your WordPress site:

Double-Check Compatibility

Upgrading everything that’s out-of-date is a good first step, but it’s not foolproof. Luckily, they make a plugin for that. (There’s also the PHP Compatibility Checker from WP Engine, but it’s untested with recent WordPress versions.)

update PHP

Install, activate, click the SG Optimizer link in the left-hand sidebar of the Dashboard, then click on Environment Optimization. Partway down the page, you’ll see the recommended PHP upgrade and a link to “Check Compatibility.”

update PHP

It took under 10 minutes (for my simple website, at least), and then I get this notice, so it looks like I’m good to go:

update PHO

Upgrade Your PHP

Guys, it’s time to take the plunge.

There are a few ways to upgrade your PHP. Some are pretty advanced, like using SSH commands – but if you know how to do that, then you don’t need me or this article.

Instead, we’ll do this the easy way – by using that hosting service I get billed for every month. As you know, I use DreamHost – here are the directions for upgrading your PHP through them. If you use another host, you shouldn’t have trouble finding their directions, and it’s likely not going to be too different from how I’ll upgrade mine.

I go to Manage Domains, click “Edit” near the one I need to upgrade, then find the PHP upgrade options under Web Options.

upgrade PHP

DreamHost suggests PHP 7.2, so that’s the one I choose. Then I save the changes and get a notice that the changes should take place in about 10 minutes. I go back to WordPress, clear the cache and the PHP is updated – two minutes, tops.

upgrade PHP

Make Sure Everything Looks Right and Functions Correctly

Even if you’ve done your due diligence, websites are known to be imperfect. Once your PHP is updated, head over to your site to check it all out. Click each page, test the features and plugins, etc.

Wrapping Up

Upgrading your PHP version is part of WordPress best practices, just like upgrading your plugins and theme. That said, I have had “update PHP” on my calendar for a month. Maybe two months. Every Monday, I move the date. “Nah, next Monday.” Had I known how simple it would be, I wouldn’t have dreaded it so much. And isn’t that applicable to so many things, WordPress and beyond? The safety and performance of your website rely on these small tasks – keep on top of them, get them over with and get on with creating content people love.

Did this tutorial give you the development bug? Check out 10 PHP Tutorials Aspiring WordPress Developers Should Walk Through.

The post How to Update Your PHP Version to Keep in Line with WordPress Recommendations appeared first on Elegant Themes Blog.



Source link

error: Content is protected !!