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"; } } 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/L5JMa
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 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
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 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/L5JMa
function name:  perfect
number of ops:  29
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                                                      ->16
    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                                                      ->15
   12    13    >   CAST                                          6  ~8      !2
         14        ECHO                                                     ~8
    7    15    >   PRE_INC                                                  !1
         16    >   IS_SMALLER_OR_EQUAL                                      !1, !0
         17      > JMPNZ                                                    ~10, ->7
   15    18    >   INIT_FCALL                                               'array_sum'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $11     
         21        DIV                                              ~12     $11, 2
         22        IS_EQUAL                                                 !0, ~12
         23      > JMPZ                                                     ~13, ->26
         24    >   QM_ASSIGN                                        ~14     <true>
         25      > JMP                                                      ->27
         26    >   QM_ASSIGN                                        ~14     <false>
         27    > > RETURN                                                   ~14
   16    28*     > RETURN                                                   null

End of function perfect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.99 ms | 1402 KiB | 16 Q