Whether you’re a certified scripting pro, an aspiring dev master or a business that has a site that uses PHP, different versions of the scripting language bring their own benefits to the table for everyone. As community support for PHP 7.4 ended in November 2022, if you’re still using that release, it could be time to move to either PHP 8.0 or beyond. 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.
PHP vs JavaScript
PHP compares to JavaScript too, in the sense that the latter can also be used as a server-side language. However, PHP has earned a reputation for being fairly easy to learn by those early in their coding journey, due to its intuitive logic and structure. JavaScript, on the other hand, is known to have a steeper learning curve, particularly as a full-stack language.
Why has community support ended 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 its own new features and updates with it.
PHP 8.2 was released in November 2022, coincided with the end of PHP 7.4's community support. As they say, one door closes, another door opens.
And speaking of open doors, PHP 8.4 is in the works, with improved bug fixes, deep cloning, as well as general updates. You can find the PHP 8.3 change logs on the official website, which were added in January 2024.
Why should you upgrade to PHP 8?
The biggest reason to upgrade 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 more quickly.
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.
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.
4. Active support available
PHP 8 receives active support, including bug fixes and security patches. On the other hand, PHP 7.4 and older versions no longer receive active support (as of 2022). This is why upgrading to PHP 8 and beyond is essential – especially if you don’t want to rely on third party support!
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 are loads of new features that you’ll love 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 are 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.
PHP 8.4
PHP 8.4 is currently still in development and is set to have tons of new features. There is no set date at the time of writing but is set to be released later in 2024.
Should I move to PHP 8?
PHP 8 brings a range of significant improvements, as well as new features to enhance the process of web development. From speed improvements to reduced memory consumption, PHP 8 also adds a powerful Just-In-Time (JIT) compiler to boost the performance of your computationally heavy applications. It also introduced new syntax features and improvements such as named arguments, attributes, match expressions, and null-safe operators to name a few.
The new version of PHP also comes with improved error handling and type systems that facilitate debugging and reduce the chances of errors. So if you want to code in a safer PHP environment, then migrating to PHP 8 is going to massively improve your workflow.
Is PHP 8 faster than PHP 7?
Yes, PHP 8 is much faster than PHP 7, thanks to the introduction of Just-In-Time (JIT) among many other updated components.
Is PHP 8 faster than Python?
When comparing the performance of PHP 8 to Python, it's not a straightforward question to answer as performance can depend largely on its use case(s).
While each language has its own strengths and weaknesses, as a general rule, PHP 8 tends to be faster than Python, at least for web-based applications, due to factors such as the new Just-In-Time (JIT) compiler introduced in PHP 8, which can significantly enhance performance for certain types of tasks. However, efficiency is highly context-dependent, and one language may outperform the other depending on specific application requirements.
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.