New in PHP 8

PHP 8, the new major PHP version, is predicted to be discharged by the tip of 2020. It’s in terribly active development immediately, thus things are doubtless to alter a great deal within the forthcoming months.

In this post I’ll keep associate degree up-to-date list of what’s expected to come: new options, performance enhancements and breaking changes. as a result of PHP eight could be a new major version, there’s a better probability of your code breaking. If you’ve maintained to this point with the most recent releases although, the upgrade shouldn’t be too arduous, since most breaking changes were deprecated before within the seven.* versions.

Besides breaking changes, PHP eight additionally brings some nice new options such as the JIT compiler and union types; and there’s a lot of to come!

New features .

Starting with new features, remember that PHP 8 is still in active development, so this list will grow over time.

#Union types RFC

Given the dynamically typed nature of PHP, there are lots of cases where union types can be useful. Union types are a collection of two or more types which indicate that either one of those can be used.

public function foo(Foo|Bar $input): int|float;

Note that void can never be part of a union type, since it indicates “no return value at all”. Furthermore, nullable unions can be written using |null, or by using the existing ? notation:

public function foo(Foo|null $foo): void;

public function bar(?Bar $bar): void;


Prev1 of 6