PHP 8.0 Adds Metadata To Classes
Written by Kay Ewbank   
Tuesday, 08 December 2020

There's a major new release of PHP with improvements including a nullsafe operator and attributes enabling the use of structured metadata with PHP's native syntax.

PHP began life 25 years ago as a simple scripting language designed to build web pages but has developed into a general server-side web language . It is now used for eight out of ten websites using server-side code. 

phplogo

This is a major upgrade to the language, with a number of notable improvements. The support for metadata for classes via attributes provides an alternative to the previous technique of parsing docblocks. Attributes are usually called annotations in other languages.

There are two new JIT compilers in the new release. The Tracing JIT, which the developers say is the most promising of the two, shows about three times better performance on synthetic benchmarks and up to two times improvement on some specific long-running applications.

phpjit

The developers say that they decided to include the JIT compilers because they've run out of other ways to improve PHP's performance using other optimization strategies. They also believe that using JIT may open the door for PHP being more frequently used in other, non-Web, CPU-intensive scenarios where PHP wasn't a language under consideration without JIT.

The addition will also offer the opportunity to develop built-in functions in PHP, instead of (or in addition to) C - without suffering the huge performance penalty that would be associated with such a strategy in the previous, non-JITted engine.

The new nullsafe operator is another improvement. It means developers can avoid the problems of the null coalescing operator, specifically that it doesn't work on method calls. The new operator means PHP has null coalescing-like behavior on methods.

Other improvements include the addition of Union types,collections of two or more types which indicate that either one of those can be used; and named arguments, so you can now pass arguments to a function based on the parameter name, rather than the parameter position.

PHP 8.0 is now available for download.

phplogo

More Information

PHP Website

Related Articles

PHP 7.4 Gets Foreign Function Interface

PHP Is Best?

PHP 7.2 With Built-in Libsodium

What PHP Does

PHP Variables and Expressions for Complete Beginners

Object-oriented HTML Generation In PHP

PHP 5.6 Released

PHP Gets A Formal Specification 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Imagine Cup 2021 - Who Will Be World Champions?
02/04/2021

For 2021 the Imagine Cup became an all-digital challenge and is now entering it's final phase with four teams selected to compete in the World Championship for a top prize of USD $75,000 and ment [ ... ]



PeachPie Reaches 1.0
30/03/2021

The developers of PeachPie have released version 1.0 of the open source development platform that can be used to treat PHP as a native .NET language. Work on version 1 of PeachPie has concentrated on  [ ... ]


More News

square

 



 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Wednesday, 09 December 2020 )