3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function bar(Bar $bar) { $bar->baz([$this, 'baz']); } protected function baz() { print 'Foobar!'.PHP_EOL; } } class Bar { public function baz(callable $baz) { $baz(); } } $foo = new Foo; $bar = new Bar; $foo->foo($bar);
based on hO6E1
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined method Foo::foo() in /in/F5o4f:21 Stack trace: #0 {main} thrown in /in/F5o4f on line 21
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Call to undefined method Foo::foo() in /in/F5o4f on line 21
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/F5o4f on line 4
Process exited with code 255.