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
FlexiSpot office furniture next to a TechRadar-branded badge that reads Big Savings.
Upgrade your home office for under $500 in the Amazon Spring Sale: My top picks and biggest savings
Beelink EQi 12 mini PC
I’ve never seen a PC with an Intel Core i3 CPU, 24GB RAM, 500GB SSD and two Gb LAN ports sell for so cheap
cybersecurity
Chinese government hackers allegedly spent years undetected in foreign phone networks
Data leak
A major Keenetic router data leak could put a million households at risk
Code Skull
Interpol operation arrests 300 suspects linked to African cybercrime rings
Insecure network with several red platforms connected through glowing data lines and a black hat hacker symbol
Multiple routers hit by new critical severity remote command injection vulnerability, with no fix in sight
Latest in News
Hornet swings their weapon in mid air
Hollow Knight: Silksong gets new Steam metadata changes, convincing everyone and their mother that the game is finally releasing this year
OpenAI logo
OpenAI just launched a free ChatGPT bible that will help you master the AI chatbot and Sora
Monster Hunter Wilds
Monster Hunter Wilds Title Update 1 launches in early April, adding new monsters and some of the best-looking armor sets I need to add to my collection
Zotac Gaming RTX 5090 Graphics Card
Nvidia Blackwell stock woes are compounded by price hikes as more RTX 5090 GPUs soar in pricing, and I’m sick and tired of it all at this point
A collage of Elizabeth Olsen's Scarlet Witch and Tatiana Maslany's She-Hulk
Marvel fans are already tired of Doomsday and Secret Wars cast gossip as two more superheroes get linked with roles in the next two Avengers movies
Four operators survey Verdansk. One holds a sniper rifle, one binoculars, another holds is landing with their parachute, while the last wears a skull mask
New Call of Duty: Warzone trailer shows a beautiful rebuilt Verdansk, but some fans want more: 'it won't be the same unfortunately'