PHP 8: New features and updates

Security Researcher
(Image credit: Shutterstock / Roman Samborskyi)

PHP is a powerful, and widely accessible, open-source programming language that is primarily used in website development. Even though we constantly see a rise in all sorts of different technologies and website-building software, PHP remains one of the most widely used languages, powering a staggering number of websites. The new version, PHP 8, promises to bring even more power and speed allowing for even better results. 

Unlike something like JavaScript, which is client-side, PHP is server-side. When the browser requests information from the server, the server executes the code and sends the result to the client. The browser then uses this information to create a web page. PHP is relatively easy to learn, fast, and compatible with almost all browsers making it a powerful tool for developers of all kinds.

About the author

Hristo Pandjarov is WordPress Initiatives Manager at SiteGround

What are the PHP 8 improvements and features?

PHP 8 went live on November 26 and will introduce a lot of improvements in speed, security and cleanness of code:

Faster Code Execution: PHP 8 is the first PHP version that has a compiler – JIT – that caches your interpreted code and generates a machine code as an output. The JIT, or “just in time” compiler promises speed improvements for complex tasks and algorithms and opens new opportunities for the PHP language to broaden its reach and applications.  

Code with Higher Quality: One of the major differences you will notice with PHP 8 is that many of the warnings and notices that were hard to catch are now classified as code exceptions or errors, which can be caught and logged. It is possible that due to this update, a lot of problems that remained hidden as notices with the previous PHP versions will now surface.

Cleaner, Shorter Code: Some of the new elements, such as the null safe operator, greatly improve the readability of the code, making it shorter and neater. The null safe operator provides functionality similar to null coalescing, but also supports method calls. Instead of nesting several “if statements” you can use the “null” operator to write all those in just 1 line of code. 

The “Union Type” Trend: In versions prior to PHP 8.0, you could only declare a single type for properties, parameters, and return types. In this latest release, there is a feature called “union types” that are a collection of two or more types which indicate that either one of those can be used.  A union type essentially declares an OR condition for multiple types in the argument type, return type or property type declaration.

The release candidate version has been available for testing for a while now. Most quality website hosting companies should already have an option for developers to test it on their platform. Since major versions often include changes that might break backward compatibility, it's better to test the release candidate version as early as possible, and prepare your code if you want to get all the benefits of the latest update.

Keeping up with the latest PHP versions is essential if you want to have fast and secure code. PHP 8 is a major and highly anticipated update, but before upgrading, it is strongly recommended to test it on a Staging version of your website first, in order to fix any incompatibility or errors in advance. For more information on the new features and other changes, you can read the NEWS file, or the UPGRADING file for a complete list of upgrading notes.

Hristo Pandjarov is WordPress Initiatives Manager at SiteGround

Latest in Pro
Eurocom Raptor X18
At $15,000, this massive 256GB RAM laptop makes Apple's MacBook Pro look affordable, tiny and very, very slow
Squarespace
Build a website for less with 10% off Squarespace subscriptions
An American flag flying outside the US Capitol building against a blue sky
The FCC is creating a security council to bolster US defenses against cyberattacks
UK Prime Minister Sir Kier Starmer
UK PM says AI should soon replace civil servants
Image depicting hands typing on a keyboard, with phishing hooks holding files, passwords and credit cards.
Microsoft warns about a new phishing campaign impersonating Booking.com
Ransomware
Microsoft uncovers sleuthy new XCSSET MacOS malware campaign
Latest in News
Google Gemini Flash 2.0 Images
I tried Gemini's new AI image generation tool - here are 5 ways to get the best art from Google's Flash 2.0
An image of the Samsung Galaxy S25 Ultra from a hands-on event
Samsung Galaxy S26 Ultra could resurrect an intriguing camera feature
Eurocom Raptor X18
At $15,000, this massive 256GB RAM laptop makes Apple's MacBook Pro look affordable, tiny and very, very slow
Cristin Milioti in Black Mirror season 7
Netflix launches trailer for Black Mirror season 7, giving us a look at its first-ever sequel episode and an unexpected returning character
A graphic of the PC Gaming Show
Get ready for a bounty of PC games on June 8, as the PC Gaming show is back
A close up of The Daily podcast from Pocket Casts' web page
‘Podcasting shouldn’t be locked behind walled gardens’: Pocket Casts slams Spotify and makes its web player free to all