3v4l.org

run code in 500+ PHP versions simultaneously
<?php function my_callback( $value, $one, $two, $three ) { echo "Params passed to callback:\n"; print_r( compact( 'value', 'one', 'two', 'three' ) ); return strtoupper( $value ); } function apply_filters( $hook_name, $value, ...$args ) { echo "Params passed to apply_filters():\n"; print_r( compact( 'hook_name', 'value', 'args' ) ); $value = call_user_func_array( 'my_callback', array( $value, ...$args ) ); return $value; } $args = [ 'three' => 3, 'two' => 2, 'one' => 1, ]; $value = call_user_func_array( 'apply_filters', array_merge( array( 'foo', 'bar' ), $args ) ); echo "value: $value\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXnqP
function name:  (null)
number of ops:  15
compiled vars:  !0 = $args, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                       !0, <array>
   21     1        INIT_FCALL                                                   'apply_filters'
          2        INIT_FCALL                                                   'array_merge'
          3        SEND_VAL                                                     <array>
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $3      
          6        SEND_ARRAY                                                   $3
          7        CHECK_UNDEF_ARGS                                             
          8        DO_FCALL                                          1  $4      
          9        ASSIGN                                                       !1, $4
   22    10        ROPE_INIT                                         3  ~7      'value%3A+'
         11        ROPE_ADD                                          1  ~7      ~7, !1
         12        ROPE_END                                          2  ~6      ~7, '%0A'
         13        ECHO                                                         ~6
         14      > RETURN                                                       1

Function my_callback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXnqP
function name:  my_callback
number of ops:  19
compiled vars:  !0 = $value, !1 = $one, !2 = $two, !3 = $three
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
    4     4        ECHO                                                         'Params+passed+to+callback%3A%0A'
    5     5        INIT_FCALL                                                   'print_r'
          6        INIT_FCALL                                                   'compact'
          7        SEND_VAL                                                     'value'
          8        SEND_VAL                                                     'one'
          9        SEND_VAL                                                     'two'
         10        SEND_VAL                                                     'three'
         11        DO_ICALL                                             $4      
         12        SEND_VAR                                                     $4
         13        DO_ICALL                                                     
    6    14        INIT_FCALL                                                   'strtoupper'
         15        SEND_VAR                                                     !0
         16        DO_ICALL                                             $6      
         17      > RETURN                                                       $6
    7    18*     > RETURN                                                       null

End of function my_callback

Function apply_filters:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GXnqP
function name:  apply_filters
number of ops:  21
compiled vars:  !0 = $hook_name, !1 = $value, !2 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV_VARIADIC                                        !2      
   10     3        ECHO                                                         'Params+passed+to+apply_filters%28%29%3A%0A'
   11     4        INIT_FCALL                                                   'print_r'
          5        INIT_FCALL                                                   'compact'
          6        SEND_VAL                                                     'hook_name'
          7        SEND_VAL                                                     'value'
          8        SEND_VAL                                                     'args'
          9        DO_ICALL                                             $3      
         10        SEND_VAR                                                     $3
         11        DO_ICALL                                                     
   12    12        INIT_FCALL                                                   'my_callback'
         13        INIT_ARRAY                                           ~5      !1
         14        ADD_ARRAY_UNPACK                                     ~5      !2
         15        SEND_ARRAY                                                   ~5
         16        CHECK_UNDEF_ARGS                                             
         17        DO_FCALL                                          1  $6      
         18        ASSIGN                                                       !1, $6
   13    19      > RETURN                                                       !1
   14    20*     > RETURN                                                       null

End of function apply_filters

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.91 ms | 3490 KiB | 19 Q