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->bar($bar);
based on F5o4f
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to Bar::baz() must be callable, array given, called in /in/Gf0ul on line 4 and defined in /in/Gf0ul:13 Stack trace: #0 /in/Gf0ul(4): Bar->baz(Array) #1 /in/Gf0ul(21): Foo->bar(Object(Bar)) #2 {main} thrown in /in/Gf0ul on line 13
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Catchable fatal error: Argument 1 passed to Bar::baz() must be callable, array given, called in /in/Gf0ul on line 4 and defined in /in/Gf0ul on line 13
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/Gf0ul on line 4
Process exited with code 255.