3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public static function bar() { return 1; } private static function baz() { return 2; } } function mapIt( callable $mapper ) { $a = array( 1, 2, 3 ); return array_map( $mapper, $a ); } $f = new Foo(); var_dump( mapIt( array( $f, 'bar' ) ) ); var_dump( mapIt( array( $f, 'baz' ) ) );
based on bO6Yt
Output for 7.0.0 - 7.3.0rc4
array(3) { [0]=> int(1) [1]=> int(1) [2]=> int(1) } Fatal error: Uncaught TypeError: Argument 1 passed to mapIt() must be callable, array given, called in /in/egqd4 on line 19 and defined in /in/egqd4:12 Stack trace: #0 /in/egqd4(19): mapIt(Array) #1 {main} thrown in /in/egqd4 on line 12
Process exited with code 255.
Output for 5.4.0 - 5.6.28
array(3) { [0]=> int(1) [1]=> int(1) [2]=> int(1) } Catchable fatal error: Argument 1 passed to mapIt() must be callable, array given, called in /in/egqd4 on line 19 and defined in /in/egqd4 on line 12
Process exited with code 255.
Output for 5.2.0 - 5.3.29
Catchable fatal error: Argument 1 passed to mapIt() must be an instance of callable, array given, called in /in/egqd4 on line 18 and defined in /in/egqd4 on line 12
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Argument 1 passed to mapIt() must be an object of class callable, called in /in/egqd4 on line 18 and defined in /in/egqd4 on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Argument 1 must be an object of class callable in /in/egqd4 on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/egqd4 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/egqd4 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/egqd4 on line 3
Process exited with code 255.