3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum() { $list = array(); $prepare = function($value) use(&$prepare, &$list) { if (is_array($value)) { return $prepare(array_merge($list, $value));//array_map($prepare, ); } $list[] = $value; }; $args = func_get_args(); array_walk($args, $prepare, $list); var_dump($list); return addition(0, $list); } function addition($sum, array &$list) { return empty($list) ? $sum : addition($sum + array_pop($list), $list); } $vars = range(1, 10); echo sum(array($vars), array(1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nBHkF
function name:  (null)
number of ops:  12
compiled vars:  !0 = $vars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 10
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   25     5        INIT_FCALL                                               'sum'
          6        INIT_ARRAY                                       ~3      !0
          7        SEND_VAL                                                 ~3
          8        SEND_VAL                                                 <array>
          9        DO_FCALL                                      0  $4      
         10        ECHO                                                     $4
         11      > RETURN                                                   1

Function sum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nBHkF
function name:  sum
number of ops:  21
compiled vars:  !0 = $list, !1 = $prepare, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnBHkF%3A5%240'
          2        BIND_LEXICAL                                             ~4, !1
          3        BIND_LEXICAL                                             ~4, !0
          4        ASSIGN                                                   !1, ~4
   13     5        FUNC_GET_ARGS                                    ~6      
          6        ASSIGN                                                   !2, ~6
   14     7        INIT_FCALL                                               'array_walk'
          8        SEND_REF                                                 !2
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
   16    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   17    15        INIT_FCALL_BY_NAME                                       'addition'
         16        SEND_VAL_EX                                              0
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $10     
         19      > RETURN                                                   $10
   18    20*     > RETURN                                                   null

End of function sum

Function %00%7Bclosure%7D%2Fin%2FnBHkF%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nBHkF
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $value, !1 = $prepare, !2 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    6     3        TYPE_CHECK                                  128          !0
          4      > JMPZ                                                     ~3, ->13
    7     5    >   INIT_DYNAMIC_CALL                                        !1
          6        INIT_FCALL                                               'array_merge'
          7        SEND_VAR                                                 !2
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        SEND_VAR_NO_REF_EX                                       $4
         11        DO_FCALL                                      0  $5      
         12      > RETURN                                                   $5
   10    13    >   ASSIGN_DIM                                               !2
         14        OP_DATA                                                  !0
   11    15      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FnBHkF%3A5%240

Function addition:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nBHkF
function name:  addition
number of ops:  17
compiled vars:  !0 = $sum, !1 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        ISSET_ISEMPTY_CV                                         !1
          3      > JMPZ                                                     ~2, ->6
          4    >   QM_ASSIGN                                        ~3      !0
          5      > JMP                                                      ->15
          6    >   INIT_FCALL_BY_NAME                                       'addition'
          7        INIT_FCALL                                               'array_pop'
          8        SEND_REF                                                 !1
          9        DO_ICALL                                         $4      
         10        ADD                                              ~5      !0, $4
         11        SEND_VAL_EX                                              ~5
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $6      
         14        QM_ASSIGN                                        ~3      $6
         15    > > RETURN                                                   ~3
   22    16*     > RETURN                                                   null

End of function addition

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.75 ms | 1403 KiB | 24 Q