3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class ack{ public function getBar(){ return null; } } $foo = new ack(); var_dump($foo ?? "empty"); var_dump($foo->getBar()->getBaz() ?? "empty");
Output for 7.0.0 - 7.3.0rc3
object(ack)#1 (0) { } Fatal error: Uncaught Error: Call to a member function getBaz() on null in /in/HnNZC:9 Stack trace: #0 {main} thrown in /in/HnNZC on line 9
Process exited with code 255.
Output for hhvm-3.15.4
object(ack)#1 (0) { } Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function getBaz() on a non-object (null)' in /in/HnNZC:9 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '?' in /in/HnNZC on line 7
Process exited with code 255.