Whether you’re a certified scripting pro, an aspiring dev master or a business who has a site that uses PHP, different versions of the scripting language bring their own benefits to the table for everyone. With community support for PHP 7.4 ending in November 2022, if you’re still using that release, it could be time to move to either PHP 8.0 or 8.1. But what does the end of community support mean and what are the biggest benefits of moving to PHP 8? That’s what we’re here to answer!


What is PHP?

For the benefit of those less familiar with it, let’s just take a quick look at what PHP is. In short, PHP is a widely-used open source scripting language largely used for creating dynamic web pages – it can collect data from forms, send emails to site users, send and receive cookies, encrypt data, be used with databases and more. It’s so popular in fact that it’s used in nearly 80% of sites.

Why is community support ending for PHP 7.4?

Every time a new version of PHP is released, that version is supported for two years. During that time, new features are added and any security issues or bugs that are reported will have a fix released to sort them out.

But, after those two years of active support, each release version will be supported for another year, but only for security issues. Throughout this year, updates are only released on a when-needed basis.

Once this third year of support has ended, the release ‘branch’ reaches end of life and is no longer supported. Your script will still run and you can still use previous versions of PHP but you’d be reliant on third-party support for security and bug fixes.

When was PHP 8 released?

The first version, PHP 8.0 was released in November 2020 (the year after PHP 7.4). It was a major update that aimed to resolve issues with PHP 7 and make PHP more developer-friendly. PHP 8.1 is the most recent version, released in November 2021, and the first minor release of the PHP 8 series, bringing it's own new features and updates with it.

The next release, PHP 8.2, will be in November 2022 when PHP 7.4 reaches the end of it's community support – as they say, one door closes, another door opens.

Why should you upgrade to PHP 8?

The biggest reason to switch to PHP 8 before November 2022 is because community support for PHP 7.4 is ending. But it’s not just about moving versions out of necessity – PHP 8 brings bags of benefits with it.

Benefits of PHP 8.0

1. Better performance

As with any newer version, PHP 8.0 has improved performance over PHP 7.4, but the biggest improvements come with additions like the Just-In-Time (JIT) compiler.

Just-In-Time (JIT)
JIT is an extension for PHP 8.0 that increases the speed of applications by how  it handles the compilation of PHP scripts. Put simply, it means more complex application code can be executed quicker.

2. New features

PHP 8 is packed full of changes compared to PHP 7.4 including plenty of features that any PHP aficionados can really make use of. Let’s take a gander and the most important ones.

Attributes

Attributes (sometimes referred to as annotations) give a new way to describe and grant special behaviours for some classes.They’re defined as a form of structured metadata which can be added to declarations of classes, properties, functions and more.

Named arguments

PHP 8 introduced named arguments, an extension of existing positional parameters. They mean that you can specify which of the arguments is passed simply by using a parameter name so you don’t have to take order into account.

example code for named arguments

Match expressions

If you’ve been round the programming block, you’ll recognise expression matching from other languages. In fact, PHP 7 has 3 different versions built into it over its lifetime. The new match expression in PHP 8 makes developer life so much easier, letting you return a value based on the given input with safer semantics than the switch operator.

Nullsafe operator

If a Null Reference Exception is the bane of your dev life, the nullsafe operator is here to save the day, helping to stop that from happening by checking if the code can be executed without errors. If you’ve ever  needed to get a value from multi-level nested objects or write code to check if a variable was set before you could use it, the nullsafe operator in PHP 8.0 will be a welcome feature.

3. More developer-friendly

PHP 8.0 gives developers the chance to build better, more robust websites and applications. It adds more consistency, transparency, clarity and efficiency with syntax improvements, great core changes and significant API upgrades, making it more developer-friendly than 7.4.

Benefits of PHP 8.1

The second iteration of PHP 8.0, PHP 8.1 builds upon everything that the 8.0 version gives us with added changes, more performance improvements and new features.

New features for devs

There’s loads of new features that you’ll be loving if you’re a PHP developer.

Enums

Please welcome to the stage, “Enums” (or “Enumerated Types” as they’re properly known)! Gone are the days of having to assign numbers against status and make sure they don’t clash. If you’re used to other programming languages you’ll take to these like a duck to water.

New array functions

If you spend your days head-deep in arrays, you’ll be glad to know there are a few cool functions being added to help with array manipulation. For example, ‘array_is_list()’ lets you tell the difference between an associative array, and a plain old list array.

PHP 7.4 added the spread operator (...) for unpacking, but that could only be used on arrays with numeric keys. PHP 8.1 allows you to unpack arrays with keys too, using the same operator.

The ‘never’ type

Recognised by frequent code users as ‘noreturn’, the newly named ‘never’ type indicates that a function will stop the program flow. This explicitly allows a function to indicate that it may ‘exit()’ or throw an exception. This is useful for static analysis tools (like Psalm and PHPStan) and some IDEs (like PhpStorm) for identifying errors that can creep into code.

Want to dive deeper into 8.1 features? We’ve got a whole blog that talks about what’s new in PHP 8.1.

PHP 8.0 or 8.1?

So if you’re thinking of moving to PHP 8, the big question is, which version do you switch to? Do you go for PHP 8.0 or 8.1?

Keep up with the times

The most obvious answer would be PHP 8.1. As the latest release, it has the most up-to-date features, better performance and won’t lose PHP community support fully until 2024. And there’s the bonus that it will put you in a great place technically for when PHP 8.2 is released.

Keep the features you need

Even though PHP 8.1 brings lots of new stuff to the table, each release does say goodbye to things as well. Before diving straight into using 8.1 you should check that there’s no code-breaking changes that will affect your project.

Some of the deprecations in PHP 8.1 include:

  • Non-compatible float to int conversions
  • The mysqli::get_client_info method and mysqli_get_client_info($param)
  • All mhash*() functions (hash Extension)
  • Both filter.default and filter.default_options INI settings
  • Deprecate autovivification on false
  • The mysqli_driver->driver_version property

If any of these look like they might cause you problems, you should double check compatibility and potentially opt for PHP 8.0.

How do you upgrade to a newer version of PHP?

Upgrading your PHP version doesn’t have to be too complicated, so if you’re not familiar with the techie stuff don’t panic. And even if you’re a coding pro, you probably have a lot on your plate, without having to spend ages figuring out how to update your PHP. Thankfully, a lot of hosting providers have their own help guides to take you through it step by step – like us!

If you’re a Fasthosts customer, you can find several guides in our knowledgebase that cover how to change your PHP version for your Web Hosting, WordPress Go, Plus and Advance packages as well as other WordPress Hosting packages.


If you’d like help from a web expert to update your site we have many trusted Partners available via our Partner Network.

Don't forget you can talk to our support team – they're available 24/7 to help you with your Fasthosts products. They’re only ever a phone call away, or you can either email them or start a conversation via live chat.