3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addViaFor(array $numbers) { $sum = 0; foreach($numbers as $number) { $sum += $number; } return $sum; } function addViaWhile(array $numbers) { $sum = 0; while($numbers) { $sum += $numbers[0]; $numbers = array_shift($numbers); } return $sum; } function addViaRecursion(array $numbers) { // } echo addViaFor([3,5]) . "\r\n"; //echo addViaWhile([4,7]) . "\r\n"; //echo addViaRecursion([5,2]) . "\r\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kC7LF
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'addviafor'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0D%0A'
          4        ECHO                                                     ~1
   33     5      > RETURN                                                   1

Function addviafor:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/kC7LF
function name:  addViaFor
number of ops:  9
compiled vars:  !0 = $numbers, !1 = $sum, !2 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, 0
    7     2      > FE_RESET_R                                       $4      !0, ->6
          3    > > FE_FETCH_R                                               $4, !2, ->6
    8     4    >   ASSIGN_OP                                     1          !1, !2
    7     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $4
   11     7      > RETURN                                                   !1
   12     8*     > RETURN                                                   null

End of function addviafor

Function addviawhile:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/kC7LF
function name:  addViaWhile
number of ops:  12
compiled vars:  !0 = $numbers, !1 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        ASSIGN                                                   !1, 0
   18     2      > JMP                                                      ->9
   19     3    >   FETCH_DIM_R                                      ~3      !0, 0
          4        ASSIGN_OP                                     1          !1, ~3
   20     5        INIT_FCALL                                               'array_shift'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !0, $5
   18     9    > > JMPNZ                                                    !0, ->3
   23    10    > > RETURN                                                   !1
   24    11*     > RETURN                                                   null

End of function addviawhile

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

End of function addviarecursion

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.07 ms | 1403 KiB | 16 Q