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 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
based on 20WRe
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AfX8n
function name:  (null)
number of ops:  56
compiled vars:  !0 = $callback, !1 = $a, !2 = $b, !3 = $c
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   QM_ASSIGN                                                !0
   6     1        QM_ASSIGN                                                !1
   7     2        INIT_ARRAY                                       ~6      !1
         3        QM_ASSIGN                                                !2
   8     4        INIT_ARRAY                                       ~8      !1
         5        QM_ASSIGN                                                !3
  11     6        INIT_FCALL                                               'my_callback'
         7        SEND_REF                                                 !1
         8        DO_FCALL                                      0          
  12     9        INIT_FCALL                                               'my_callback'
        10        SEND_UNPACK                                              !2
        11        DO_FCALL                                      0          
  13    12        INIT_FCALL                                               'my_callback'
        13        SEND_UNPACK                                              !3
        14        DO_FCALL                                      0          
  16    15        INIT_DYNAMIC_CALL                                        !0
        16        SEND_VAR_EX                                              !1
        17        DO_FCALL                                      0          
  17    18        INIT_DYNAMIC_CALL                                        !0
        19        SEND_UNPACK                                              !2
        20        DO_FCALL                                      0          
  18    21        INIT_DYNAMIC_CALL                                        !0
        22        SEND_UNPACK                                              !3
        23        DO_FCALL                                      0          
  20    24        INIT_USER_CALL                                1          'call_user_func', !0
        25        SEND_USER                                                <true>
        26        DO_FCALL                                      0          
  21    27        INIT_USER_CALL                                1          'call_user_func', !0
        28        SEND_USER                                                !1
        29        DO_FCALL                                      0          
  22    30        INIT_FCALL                                               'call_user_func'
        31        SEND_VAR                                                 !0
        32        SEND_UNPACK                                              !2
        33        DO_ICALL                                                 
  23    34        INIT_FCALL                                               'call_user_func'
        35        SEND_VAR                                                 !0
        36        SEND_UNPACK                                              !3
        37        DO_ICALL                                                 
  25    38        INIT_USER_CALL                                0          'call_user_func_array', !0
        39        SEND_ARRAY                                               <array>
        40        DO_FCALL                                      0          
  26    41        INIT_USER_CALL                                0          'call_user_func_array', !0
        42        INIT_ARRAY                                       ~21     !1
        43        SEND_ARRAY                                               ~21
        44        DO_FCALL                                      0          
  27    45        INIT_USER_CALL                                0          'call_user_func_array', !0
        46        SEND_ARRAY                                               !2
        47        DO_FCALL                                      0          
  28    48        INIT_USER_CALL                                0          'call_user_func_array', !0
        49        INIT_ARRAY                                       ~24     !1
        50        SEND_ARRAY                                               ~24
        51        DO_FCALL                                      0          
  29    52        INIT_USER_CALL                                0          'call_user_func_array', !0
        53        SEND_ARRAY                                               !3
        54        DO_FCALL                                      0          
        55      > RETURN                                                   1

Function my_callback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AfX8n
function name:  my_callback
number of ops:  2
compiled vars:  !0 = $param
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
         1      > RETURN                                                   null

End of function my_callback

Generated using Vulcan Logic Dumper, using php 7.4.0