3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRandomString( $length = 8 ) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $digits = '0123456789'; $string = ''; for( $i = 0; $i < 5; $i++ ) { $string .= $digits[ mt_rand( 0, strlen( $digits ) - 1 ) ]; } for( $i = 5; $i < $length; $i++ ) { $string .= $characters[ mt_rand( 0, strlen( $characters ) - 1 ) ]; } $array = str_split( $string ); shuffle( $array ); return implode( '', $array ); } for ($i = 0; $i < 10; $i++) { echo getRandomString() . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
Branch analysis from position: 2
filename:       /in/tLUq7
function name:  (null)
number of ops:  10
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->7
   25     2    >   INIT_FCALL                                               'getrandomstring'
          3        DO_FCALL                                      0  $2      
          4        CONCAT                                           ~3      $2, '%0A'
          5        ECHO                                                     ~3
   24     6        PRE_INC                                                  !0
          7    >   IS_SMALLER                                               !0, 10
          8      > JMPNZ                                                    ~5, ->2
   26     9    > > RETURN                                                   1

Function getrandomstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 6
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 19
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 19
Branch analysis from position: 30
Branch analysis from position: 19
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 6
Branch analysis from position: 17
Branch analysis from position: 6
filename:       /in/tLUq7
function name:  getRandomString
number of ops:  43
compiled vars:  !0 = $length, !1 = $characters, !2 = $digits, !3 = $string, !4 = $i, !5 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      8
    5     1        ASSIGN                                                   !1, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    6     2        ASSIGN                                                   !2, '0123456789'
    7     3        ASSIGN                                                   !3, ''
    9     4        ASSIGN                                                   !4, 0
          5      > JMP                                                      ->15
   11     6    >   INIT_FCALL                                               'mt_rand'
          7        SEND_VAL                                                 0
          8        STRLEN                                           ~10     !2
          9        SUB                                              ~11     ~10, 1
         10        SEND_VAL                                                 ~11
         11        DO_ICALL                                         $12     
         12        FETCH_DIM_R                                      ~13     !2, $12
         13        ASSIGN_OP                                     8          !3, ~13
    9    14        PRE_INC                                                  !4
         15    >   IS_SMALLER                                               !4, 5
         16      > JMPNZ                                                    ~16, ->6
   14    17    >   ASSIGN                                                   !4, 5
         18      > JMP                                                      ->28
   16    19    >   INIT_FCALL                                               'mt_rand'
         20        SEND_VAL                                                 0
         21        STRLEN                                           ~18     !1
         22        SUB                                              ~19     ~18, 1
         23        SEND_VAL                                                 ~19
         24        DO_ICALL                                         $20     
         25        FETCH_DIM_R                                      ~21     !1, $20
         26        ASSIGN_OP                                     8          !3, ~21
   14    27        PRE_INC                                                  !4
         28    >   IS_SMALLER                                               !4, !0
         29      > JMPNZ                                                    ~24, ->19
   19    30    >   INIT_FCALL                                               'str_split'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $25     
         33        ASSIGN                                                   !5, $25
   20    34        INIT_FCALL                                               'shuffle'
         35        SEND_REF                                                 !5
         36        DO_ICALL                                                 
   21    37        INIT_FCALL                                               'implode'
         38        SEND_VAL                                                 ''
         39        SEND_VAR                                                 !5
         40        DO_ICALL                                         $28     
         41      > RETURN                                                   $28
   22    42*     > RETURN                                                   null

End of function getrandomstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.88 ms | 1016 KiB | 18 Q