3v4l.org

run code in 300+ PHP versions simultaneously
<?php function perfect($n) { if ($n < 1) { echo "Number has to be Positive."; return false; } for($i = 1; $i <= $n; $i++) { if ($n % $i == 0) { $factors[] = $i; } } return ($n == array_sum($factors) / 2) ? true : false; echo "$n $factors [$i]"; } perfect(42); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKmJb
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'perfect'
          1        SEND_VAL                                                 42
          2        DO_FCALL                                      0          
   18     3      > RETURN                                                   1

Function perfect:
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 = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 7
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 7
Branch analysis from position: 15
Branch analysis from position: 7
Branch analysis from position: 12
filename:       /in/uKmJb
function name:  perfect
number of ops:  33
compiled vars:  !0 = $n, !1 = $i, !2 = $factors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        IS_SMALLER                                               !0, 1
          2      > JMPZ                                                     ~3, ->5
    4     3    >   ECHO                                                     'Number+has+to+be+Positive.'
    5     4      > RETURN                                                   <false>
    7     5    >   ASSIGN                                                   !1, 1
          6      > JMP                                                      ->13
    8     7    >   MOD                                              ~5      !0, !1
          8        IS_EQUAL                                                 ~5, 0
          9      > JMPZ                                                     ~6, ->12
    9    10    >   ASSIGN_DIM                                               !2
         11        OP_DATA                                                  !1
    7    12    >   PRE_INC                                                  !1
         13    >   IS_SMALLER_OR_EQUAL                                      !1, !0
         14      > JMPNZ                                                    ~9, ->7
   12    15    >   INIT_FCALL                                               'array_sum'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $10     
         18        DIV                                              ~11     $10, 2
         19        IS_EQUAL                                                 !0, ~11
         20      > JMPZ                                                     ~12, ->23
         21    >   QM_ASSIGN                                        ~13     <true>
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~13     <false>
         24    > > RETURN                                                   ~13
   13    25*       ROPE_INIT                                     6  ~15     !0
         26*       ROPE_ADD                                      1  ~15     ~15, '+'
         27*       ROPE_ADD                                      2  ~15     ~15, !2
         28*       ROPE_ADD                                      3  ~15     ~15, '+%5B'
         29*       ROPE_ADD                                      4  ~15     ~15, !1
         30*       ROPE_END                                      5  ~14     ~15, '%5D'
         31*       ECHO                                                     ~14
   14    32*     > RETURN                                                   null

End of function perfect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.76 ms | 1403 KiB | 16 Q