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

End of function random_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.63 ms | 1403 KiB | 16 Q