3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fibIter($n) { if ($n < 2) { return $n; } $fibPrev = 0; $fib = 1; foreach (range(1, $n-1) as $i) { list($fibPrev, $fib) = array($fib, $fib + $fibPrev); } return $fib; } function factorial($number) { if ($number < 2) { return 1; } else { return ($number * factorial($number-1)); } } //echo fibIter(20); echo factorial(31); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mSRvI
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'factorial'
          1        SEND_VAL                                                 31
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   25     4      > RETURN                                                   1

Function fibiter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 22
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/mSRvI
function name:  fibIter
number of ops:  25
compiled vars:  !0 = $n, !1 = $fibPrev, !2 = $fib, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        IS_SMALLER                                               !0, 2
          2      > JMPZ                                                     ~4, ->4
    4     3    > > RETURN                                                   !0
    6     4    >   ASSIGN                                                   !1, 0
    7     5        ASSIGN                                                   !2, 1
    8     6        INIT_FCALL                                               'range'
          7        SEND_VAL                                                 1
          8        SUB                                              ~7      !0, 1
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                         $8      
         11      > FE_RESET_R                                       $9      $8, ->22
         12    > > FE_FETCH_R                                               $9, !3, ->22
    9    13    >   INIT_ARRAY                                       ~10     !2
         14        ADD                                              ~11     !2, !1
         15        ADD_ARRAY_ELEMENT                                ~10     ~11
         16        FETCH_LIST_R                                     $12     ~10, 0
         17        ASSIGN                                                   !1, $12
         18        FETCH_LIST_R                                     $14     ~10, 1
         19        ASSIGN                                                   !2, $14
         20        FREE                                                     ~10
    8    21      > JMP                                                      ->12
         22    >   FE_FREE                                                  $9
   11    23      > RETURN                                                   !2
   12    24*     > RETURN                                                   null

End of function fibiter

Function factorial:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mSRvI
function name:  factorial
number of ops:  12
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        IS_SMALLER                                               !0, 2
          2      > JMPZ                                                     ~1, ->5
   18     3    > > RETURN                                                   1
          4*       JMP                                                      ->11
   20     5    >   INIT_FCALL_BY_NAME                                       'factorial'
          6        SUB                                              ~2      !0, 1
          7        SEND_VAL_EX                                              ~2
          8        DO_FCALL                                      0  $3      
          9        MUL                                              ~4      !0, $3
         10      > RETURN                                                   ~4
   22    11*     > RETURN                                                   null

End of function factorial

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.45 ms | 1403 KiB | 16 Q