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, ''], [], ]; $ex->match($cases[0]); $ex->match($cases[1]);
based on 48OgC
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to Example::match() must be callable, array given, called in /in/2idHZ on line 25 and defined in /in/2idHZ:5 Stack trace: #0 /in/2idHZ(25): Example->match(Array) #1 {main} thrown in /in/2idHZ on line 5
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Catchable fatal error: Argument 1 passed to Example::match() must be callable, array given, called in /in/2idHZ on line 25 and defined in /in/2idHZ on line 5
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/2idHZ on line 21
Process exited with code 255.