3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function bar() { return 'bar'; } } $services = []; function foo() { global $services; return $services['foo'] = new Foo(); } // $services['foo'] = new Foo(); echo (isset($services['foo']) ? $services['foo'] : foo())->bar();
based on JhWeb
Output for 7.0.32 - 7.2.12
bar
Output for 5.6.38
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in /in/rspdo on line 17
Process exited with code 255.