3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rcg = new RandomChar(GenType::Digits_only,10); echo $rcg->generate(); class RandomChar { public $genType; public $size; function __construct($genType,$size) { $this->genType = $genType; $this->size = $size; } function generate() { $generated = ""; switch ($this->genType) { case GenType::Digits_only: for ($index = 0; $index < $this->size; $index++) { $generated = $generated + $this->generateDigitOnly(); } break; default: break; } return $generated; } function generateDigitOnly() { $num_array = array('0','1','2','3','4','5','6','7','8','9'); $rand_keys = array_rand($num_array, 1); return $rand_keys[0]; } } class GenType { const Digits_only = 0; const Letters_Lowercase = 1; const Letters_Uppercase = 2; const Letters_LowerUppercase = 3; const Digits_Lowercase = 4; const Digits_Uppercase = 5; const Digits_LowerUppercase = 6; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BkEOp
function name:  (null)
number of ops:  10
compiled vars:  !0 = $rcg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $1      'RandomChar'
          1        FETCH_CLASS_CONSTANT                             ~2      'GenType', 'Digits_only'
          2        SEND_VAL_EX                                              ~2
          3        SEND_VAL_EX                                              10
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
    3     6        INIT_METHOD_CALL                                         !0, 'generate'
          7        DO_FCALL                                      0  $5      
          8        ECHO                                                     $5
   43     9      > RETURN                                                   1

Class RandomChar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BkEOp
function name:  __construct
number of ops:  7
compiled vars:  !0 = $genType, !1 = $size
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN_OBJ                                               'genType'
          3        OP_DATA                                                  !0
   12     4        ASSIGN_OBJ                                               'size'
          5        OP_DATA                                                  !1
   13     6      > RETURN                                                   null

End of function __construct

Function generate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
Branch analysis from position: 8
filename:       /in/BkEOp
function name:  generate
number of ops:  21
compiled vars:  !0 = $generated, !1 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, ''
   17     1        FETCH_OBJ_R                                      ~3      'genType'
   18     2        FETCH_CLASS_CONSTANT                             ~5      'GenType', 'Digits_only'
          3        CASE                                                     ~3, ~5
          4      > JMPNZ                                                    ~4, ->6
          5    > > JMP                                                      ->17
   19     6    >   ASSIGN                                                   !1, 0
          7      > JMP                                                      ->13
   20     8    >   INIT_METHOD_CALL                                         'generateDigitOnly'
          9        DO_FCALL                                      0  $7      
         10        ADD                                              ~8      !0, $7
         11        ASSIGN                                                   !0, ~8
   19    12        PRE_INC                                                  !1
         13    >   FETCH_OBJ_R                                      ~11     'size'
         14        IS_SMALLER                                               !1, ~11
         15      > JMPNZ                                                    ~12, ->8
   22    16    > > JMP                                                      ->18
   24    17    > > JMP                                                      ->18
         18    >   FREE                                                     ~3
   26    19      > RETURN                                                   !0
   27    20*     > RETURN                                                   null

End of function generate

Function generatedigitonly:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BkEOp
function name:  generateDigitOnly
number of ops:  9
compiled vars:  !0 = $num_array, !1 = $rand_keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   30     1        INIT_FCALL                                               'array_rand'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   31     6        FETCH_DIM_R                                      ~5      !1, 0
          7      > RETURN                                                   ~5
   32     8*     > RETURN                                                   null

End of function generatedigitonly

End of class RandomChar.

Class GenType: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.97 ms | 1015 KiB | 14 Q