3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public static $bar = ['foo' => 1, 'bar' => 2]; public static function baz ($name) { return self::$bar[$name]; } } $item = ['name' => 'bar']; $baz = ['bar' => 'baz']; echo Foo::$bar[$item['name']]; echo Foo::$baz[$item['name']]();
based on eg7UZ
Output for 7.0.0 - 7.3.0rc3
2 Fatal error: Uncaught Error: Access to undeclared static property: Foo::$baz in /in/iViK2:10 Stack trace: #0 {main} thrown in /in/iViK2 on line 10
Process exited with code 255.
Output for hhvm-3.15.4
2 Fatal error: Uncaught Error: Invalid static property access: Foo::baz in /in/iViK2:10 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
2 Warning: Missing argument 1 for Foo::baz(), called in /in/iViK2 on line 10 and defined in /in/iViK2 on line 5 Notice: Undefined variable: name in /in/iViK2 on line 5 Notice: Undefined index: in /in/iViK2 on line 5