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; } else { echo "$factors[1] $factors[2] $factors[3]"; } } 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/LanSr
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 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 7
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 7
Branch analysis from position: 25
Branch analysis from position: 7
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 7
Branch analysis from position: 25
Branch analysis from position: 7
filename:       /in/LanSr
function name:  perfect
number of ops:  36
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                                                      ->23
    8     7    >   MOD                                              ~5      !0, !1
          8        IS_EQUAL                                                 ~5, 0
          9      > JMPZ                                                     ~6, ->13
    9    10    >   ASSIGN_DIM                                               !2
         11        OP_DATA                                                  !1
         12      > JMP                                                      ->22
   12    13    >   FETCH_DIM_R                                      ~8      !2, 1
         14        ROPE_INIT                                     5  ~12     ~8
         15        ROPE_ADD                                      1  ~12     ~12, '+'
         16        FETCH_DIM_R                                      ~9      !2, 2
         17        ROPE_ADD                                      2  ~12     ~12, ~9
         18        ROPE_ADD                                      3  ~12     ~12, '+'
         19        FETCH_DIM_R                                      ~10     !2, 3
         20        ROPE_END                                      4  ~11     ~12, ~10
         21        ECHO                                                     ~11
    7    22    >   PRE_INC                                                  !1
         23    >   IS_SMALLER_OR_EQUAL                                      !1, !0
         24      > JMPNZ                                                    ~16, ->7
   15    25    >   INIT_FCALL                                               'array_sum'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $17     
         28        DIV                                              ~18     $17, 2
         29        IS_EQUAL                                                 !0, ~18
         30      > JMPZ                                                     ~19, ->33
         31    >   QM_ASSIGN                                        ~20     <true>
         32      > JMP                                                      ->34
         33    >   QM_ASSIGN                                        ~20     <false>
         34    > > RETURN                                                   ~20
   16    35*     > RETURN                                                   null

End of function perfect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.54 ms | 1403 KiB | 16 Q