3v4l.org

run code in 300+ PHP versions simultaneously
<?php function random_string($charcount = 8, $mode = 0, $capsonly = 0) { /* 0 = alphanumeric 1 = letters only 2 = numbers only */ $chars_alpha_cap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $chars_alpha_low = 'abcdefghijklmnopqrstuvwxyz'; $chars_num = '0123456789'; if ($capsonly) { $chars_alpha_cap = ''; $chars_alpha_low = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; } switch ($mode) { case 1: $chars = $chars_alpha_cap . $chars_alpha_low; break; case 2: $chars = $chars_num; break; default: $chars = $chars_alpha_cap . $chars_alpha_low . $chars_num; } $rand = false; for ($i = 0; $i < $charcount; $i++) { $rand .= $chars[mt_rand(0, strlen($chars) - 1)]; } return $rand; } echo random_string(64,0,0);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mnesW
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'random_string'
          1        SEND_VAL                                                 64
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 0
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
          6      > RETURN                                                   1

Function random_string:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 25
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 25
Branch analysis from position: 36
Branch analysis from position: 25
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 9
filename:       /in/mnesW
function name:  random_string
number of ops:  38
compiled vars:  !0 = $charcount, !1 = $mode, !2 = $capsonly, !3 = $chars_alpha_cap, !4 = $chars_alpha_low, !5 = $chars_num, !6 = $chars, !7 = $rand, !8 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      8
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      0
    7     3        ASSIGN                                                   !3, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    8     4        ASSIGN                                                   !4, 'abcdefghijklmnopqrstuvwxyz'
    9     5        ASSIGN                                                   !5, '0123456789'
   11     6      > JMPZ                                                     !2, ->9
   12     7    >   ASSIGN                                                   !3, ''
   13     8        ASSIGN                                                   !4, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   17     9    >   IS_EQUAL                                                 !1, 1
         10      > JMPNZ                                                    ~14, ->14
   20    11    >   IS_EQUAL                                                 !1, 2
         12      > JMPNZ                                                    ~14, ->17
         13    > > JMP                                                      ->19
   18    14    >   CONCAT                                           ~15     !3, !4
         15        ASSIGN                                                   !6, ~15
   19    16      > JMP                                                      ->22
   21    17    >   ASSIGN                                                   !6, !5
   22    18      > JMP                                                      ->22
   24    19    >   CONCAT                                           ~18     !3, !4
         20        CONCAT                                           ~19     ~18, !5
         21        ASSIGN                                                   !6, ~19
   27    22    >   ASSIGN                                                   !7, <false>
   29    23        ASSIGN                                                   !8, 0
         24      > JMP                                                      ->34
   30    25    >   INIT_FCALL                                               'mt_rand'
         26        SEND_VAL                                                 0
         27        STRLEN                                           ~23     !6
         28        SUB                                              ~24     ~23, 1
         29        SEND_VAL                                                 ~24
         30        DO_ICALL                                         $25     
         31        FETCH_DIM_R                                      ~26     !6, $25
         32        ASSIGN_OP                                     8          !7, ~26
   29    33        PRE_INC                                                  !8
         34    >   IS_SMALLER                                               !8, !0
         35      > JMPNZ                                                    ~29, ->25
   33    36    > > RETURN                                                   !7
   35    37*     > RETURN                                                   null

End of function random_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.12 ms | 1403 KiB | 16 Q