3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Sample { private string $instantiatedViaConstructor; private ?string $notInstantiated; public function __construct(string $instantiatedViaConstructor) { $this->instantiatedViaConstructor = $instantiatedViaConstructor; } public function getNotInstantiated(): ?string { return $this->notInstantiated; } public function getWorkingNotInstantiated(): ?string { return $this->notInstantiated ?? null; } } var_dump((new Sample('foo'))->getWorkingNotInstantiated()); var_dump((new Sample('foo'))->getNotInstantiated());

preferences:
111.55 ms | 1529 KiB | 5 Q