3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Example { public function match(callable $cb) { echo $cb(); } } class Callee { public function yo() { return "If I show up, I'm allowed to do this!"; } } $ex = new Example(); $callee = new Callee(); $cases = [ [$callee, 'yo'], [$callee, ''], ]; $ex->match($cases[0]); $ex->match($cases[1]);
based on 2idHZ
Output for 7.0.0 - 7.2.0
If I show up, I'm allowed to do this! Fatal error: Uncaught TypeError: Argument 1 passed to Example::match() must be callable, array given, called in /in/onm9i on line 26 and defined in /in/onm9i:5 Stack trace: #0 /in/onm9i(26): Example->match(Array) #1 {main} thrown in /in/onm9i on line 5
Process exited with code 255.
Output for 5.4.9 - 5.6.28
If I show up, I'm allowed to do this! Catchable fatal error: Argument 1 passed to Example::match() must be callable, array given, called in /in/onm9i on line 26 and defined in /in/onm9i on line 5
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/onm9i on line 21
Process exited with code 255.