What’s New in PHP 8 ?

 

Union types

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

The nullsafe operator

$dateAsString = $startDate ? $startDate->asDateTimeString() : null;

$dateAsString = $booking->getStartDate()?->asDateTimeString();

New mixed type

function bar(): ?mixed {}

Throw expression

$triggerError = fn () => throw new MyError();

$foo = $bar[‘offset’] ?? throw new OffsetDoesNotExist(‘offset’);

READ -> https://stitcher.io/blog/new-in-php-8

Comments

Popular posts from this blog

Best PHP comment DockBlock !

How to fix pgDump dbeaver ?