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(5); echo $newfactorial->result(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mV83A
function name:  (null)
number of ops:  8
compiled vars:  !0 = $newfactorial
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'factorial_of_a_number'
          1        SEND_VAL_EX                                              5
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   25     4        INIT_METHOD_CALL                                         !0, 'result'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   26     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/mV83A
function name:  __construct
number of ops:  11
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        TYPE_CHECK                                   16  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
    9     4    >   NEW                                              $3      'InvalidArgumentException'
          5        SEND_VAL_EX                                              'Not+a+number+or+missing+argument'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
   11     8    >   ASSIGN_OBJ                                               '_n'
          9        OP_DATA                                                  !0
   12    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/mV83A
function name:  result
number of ops:  10
compiled vars:  !0 = $factorial, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 1
   16     1        ASSIGN                                                   !1, 1
          2      > JMP                                                      ->5
   18     3    >   ASSIGN_OP                                     3          !0, !1
   16     4        PRE_INC                                                  !1
          5    >   FETCH_OBJ_R                                      ~6      '_n'
          6        IS_SMALLER_OR_EQUAL                                      !1, ~6
          7      > JMPNZ                                                    ~7, ->3
   20     8    > > RETURN                                                   !0
   21     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:
159.62 ms | 1403 KiB | 13 Q