3v4l.org

run code in 200+ PHP versions simultaneously
<?php function my_callback( &$param ) {} $callback = 'my_callback'; $a = true; $b = array( $a ); $c = array( &$a ); //my_callback( true ); // Fatal error: passing a value when reference is expected. my_callback( $a ); // OK //$callback( true ); // Fatal error: passing a value when reference is expected. $callback( $a ); // OK call_user_func( $callback, true ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func( $callback, $a ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func( $callback, ...$b ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func( $callback, ...$c ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, array( true ) ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, array( $a ) ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, $b ); // Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, array( &$a ) ); // OK call_user_func_array( $callback, $c ); // OK
based on hOGdR
Output for 7.1.0 - 7.4.6
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 16 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 17 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 18 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 19 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 21 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 23
Output for 7.0.0 - 7.0.8, 7.0.10 - 7.0.33
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 18 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 19 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 21 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 23
Output for 7.0.9
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 17 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 18 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 19 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 21 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 23
Output for 5.6.0 - 5.6.40
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 18 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/4fEA9 on line 23
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.5.38
Parse error: syntax error, unexpected '.' in /in/4fEA9 on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '.' in /in/4fEA9 on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4fEA9 on line 18
Process exited with code 255.