3v4l.org

run code in 300+ 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 my_callback( ...$b ); // OK my_callback( ...$c ); // OK //$callback( true ); // Fatal error: passing a value when reference is expected. $callback( $a ); // OK $callback( ...$b ); // OK $callback( ...$c ); // OK call_user_func( $callback, true ); // PHP 7.1+: Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func( $callback, $a ); // PHP 7.1+: Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func( $callback, ...$b ); // PHP 5.6+: Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func( $callback, ...$c ); // PHP 7.0+: Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, array( true ) ); // PHP 7.0+: Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, array( $a ) ); // PHP 7.0+: Warning: Parameter 1 to my_callback() expected to be a reference, value given call_user_func_array( $callback, $b ); // PHP 5.6: 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
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1 - 8.4.2
Warning: my_callback(): Argument #1 ($param) must be passed by reference, value given in /in/AfX8n on line 20 Warning: my_callback(): Argument #1 ($param) must be passed by reference, value given in /in/AfX8n on line 21 Warning: my_callback(): Argument #1 ($param) must be passed by reference, value given in /in/AfX8n on line 22 Warning: my_callback(): Argument #1 ($param) must be passed by reference, value given in /in/AfX8n on line 23 Warning: my_callback(): Argument #1 ($param) must be passed by reference, value given in /in/AfX8n on line 25 Warning: my_callback(): Argument #1 ($param) must be passed by reference, value given in /in/AfX8n on line 26
Output for 7.1.0 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 20 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 21 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 23 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 25 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 26
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/AfX8n on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 23 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 25 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 26
Output for 7.0.9
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 21 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 23 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 25 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 26
Output for 5.6.0 - 5.6.40
Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 22 Warning: Parameter 1 to my_callback() expected to be a reference, value given in /in/AfX8n on line 27
Output for 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '.' in /in/AfX8n on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '.', expecting ')' in /in/AfX8n on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '.', expecting ')' in /in/AfX8n on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/AfX8n on line 12
Process exited with code 255.

preferences:
105.34 ms | 418 KiB | 5 Q