3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ref( &$ref ) { var_dump( $ref ); } $func = 'ref'; $foo = 'native'; ref( $foo ); $foo = 'variable'; $func( $foo ); $foo = 'call_user_func_array'; call_user_func_array( $func, array( &$foo ) ); $foo = 'call_user_func'; call_user_func( $func, $foo );
Output for 8.0.0 - 8.0.12, 8.1rc1 - rc3
string(6) "native" string(8) "variable" string(20) "call_user_func_array" Warning: ref(): Argument #1 ($ref) must be passed by reference, value given in /in/fESuN on line 16 string(14) "call_user_func"
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25
string(6) "native" string(8) "variable" string(20) "call_user_func_array" Warning: Parameter 1 to ref() expected to be a reference, value given in /in/fESuN on line 16 string(14) "call_user_func"
Output for 7.0.0 - 7.0.8, 7.0.10 - 7.0.33
string(6) "native" string(8) "variable" string(20) "call_user_func_array" string(14) "call_user_func"
Output for 5.6.0 - 5.6.40, 7.0.9
string(6) "native" string(8) "variable" string(20) "call_user_func_array" Warning: Parameter 1 to ref() expected to be a reference, value given in /in/fESuN on line 16

preferences:
32.1 ms | 464 KiB | 5 Q