3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { function getN(){return 5;} function ret(){return $this;} function retN(){return null;} } class NullPerson extends Person { function getN(){return 0;} function ret(){return $this;} function retN(){return null;} } $a = new Person(); $b = null; var_dump(($a??new NullPerson())->getN(), ($b??new NullPerson())->getN());

preferences:
44.46 ms | 402 KiB | 5 Q