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; echo "$i is a factor of $n." . PHP_EOL; } else { } } return ($n == array_sum($factors) / 2) ? true : false; } perfect(42); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bhed2
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'perfect'
          1        SEND_VAL                                                 42
          2        DO_FCALL                                      0          
   20     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 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
Branch analysis from position: 7
Branch analysis from position: 19
filename:       /in/bhed2
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                                                      ->20
    8     7    >   MOD                                              ~5      !0, !1
          8        IS_EQUAL                                                 ~5, 0
          9      > JMPZ                                                     ~6, ->19
    9    10    >   ASSIGN_DIM                                               !2
         11        OP_DATA                                                  !1
   10    12        ROPE_INIT                                     4  ~9      !1
         13        ROPE_ADD                                      1  ~9      ~9, '+is+a+factor+of+'
         14        ROPE_ADD                                      2  ~9      ~9, !0
         15        ROPE_END                                      3  ~8      ~9, '.'
         16        CONCAT                                           ~11     ~8, '%0A'
         17        ECHO                                                     ~11
         18      > JMP                                                      ->19
    7    19    >   PRE_INC                                                  !1
         20    >   IS_SMALLER_OR_EQUAL                                      !1, !0
         21      > JMPNZ                                                    ~13, ->7
   15    22    >   INIT_FCALL                                               'array_sum'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $14     
         25        DIV                                              ~15     $14, 2
         26        IS_EQUAL                                                 !0, ~15
         27      > JMPZ                                                     ~16, ->30
         28    >   QM_ASSIGN                                        ~17     <true>
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~17     <false>
         31    > > RETURN                                                   ~17
   16    32*     > RETURN                                                   null

End of function perfect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.96 ms | 1403 KiB | 16 Q