3v4l.org

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

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

End of function add

Function %00%7Bclosure%7D%2Fin%2FcR67D%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cR67D
function name:  {closure}
number of ops:  17
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, ->14
    7     5    >   INIT_FCALL                                               'array_map'
          6        SEND_VAR                                                 !1
          7        INIT_FCALL                                               'array_merge'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                         $5      
         13      > RETURN                                                   $5
   10    14    >   ASSIGN_DIM                                               !2
         15        OP_DATA                                                  !0
   11    16      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcR67D%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/cR67D
function name:  addition
number of ops:  17
compiled vars:  !0 = $sum, !1 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     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
   18    16*     > RETURN                                                   null

End of function addition

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.75 ms | 1403 KiB | 22 Q