3v4l.org

run code in 300+ PHP versions simultaneously
<?php class factorial_of_a_number{ protected $n; public function __construct($n){ if(!is_int($n)){ throw new InvalidArgumentException('Not A Number or missing argument'); } $this->n = $n; } public function result(){ $factorial = 1; for($i=1;$i<= $this ->_n;$i++){ $factorial *= $i; } return $factorial; } } $newfactorial = new factorial_of_a_number(2); echo $newfactorial->result();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hg7Vk
function name:  (null)
number of ops:  8
compiled vars:  !0 = $newfactorial
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'factorial_of_a_number'
          1        SEND_VAL_EX                                              2
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   21     4        INIT_METHOD_CALL                                         !0, 'result'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
          7      > RETURN                                                   1

Class factorial_of_a_number:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hg7Vk
function name:  __construct
number of ops:  11
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        TYPE_CHECK                                   16  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
    6     4    >   NEW                                              $3      'InvalidArgumentException'
          5        SEND_VAL_EX                                              'Not+A+Number+or+missing+argument'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
    8     8    >   ASSIGN_OBJ                                               'n'
          9        OP_DATA                                                  !0
    9    10      > RETURN                                                   null

End of function __construct

Function result:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/Hg7Vk
function name:  result
number of ops:  10
compiled vars:  !0 = $factorial, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 1
   13     1        ASSIGN                                                   !1, 1
          2      > JMP                                                      ->5
   14     3    >   ASSIGN_OP                                     3          !0, !1
   13     4        PRE_INC                                                  !1
          5    >   FETCH_OBJ_R                                      ~6      '_n'
          6        IS_SMALLER_OR_EQUAL                                      !1, ~6
          7      > JMPNZ                                                    ~7, ->3
   16     8    > > RETURN                                                   !0
   17     9*     > RETURN                                                   null

End of function result

End of class factorial_of_a_number.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.99 ms | 1399 KiB | 13 Q