3v4l.org

run code in 300+ PHP versions simultaneously
<?php function randomString($length=10,$symbols=false) { $grabbag = "abcdefghijklmnopqrstuvwxyz0123456789"; if ($symbols) { $grabbag .= '!@#$%^&*()_+{}-=[]|\\:";\'<,>.?/~`'; } $string = ''; $len = strlen($grabbag)-1; while ($length--) { $char = $grabbag[rand(0,$len)]; if (rand(0,1)) { $char = strtoupper($char); } $string .= $char; } return $string; } echo randomString(20,true);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oBMHW
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'randomstring'
          1        SEND_VAL                                                 20
          2        SEND_VAL                                                 <true>
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function randomstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 10
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 10
Branch analysis from position: 28
Branch analysis from position: 10
Branch analysis from position: 25
Branch analysis from position: 5
filename:       /in/oBMHW
function name:  randomString
number of ops:  30
compiled vars:  !0 = $length, !1 = $symbols, !2 = $grabbag, !3 = $string, !4 = $len, !5 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      10
          1        RECV_INIT                                        !1      <false>
    3     2        ASSIGN                                                   !2, 'abcdefghijklmnopqrstuvwxyz0123456789'
    4     3      > JMPZ                                                     !1, ->5
    5     4    >   ASSIGN_OP                                     8          !2, '%21%40%23%24%25%5E%26%2A%28%29_%2B%7B%7D-%3D%5B%5D%7C%5C%3A%22%3B%27%3C%2C%3E.%3F%2F%7E%60'
    7     5    >   ASSIGN                                                   !3, ''
    8     6        STRLEN                                           ~9      !2
          7        SUB                                              ~10     ~9, 1
          8        ASSIGN                                                   !4, ~10
    9     9      > JMP                                                      ->26
   10    10    >   INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 0
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $12     
         14        FETCH_DIM_R                                      ~13     !2, $12
         15        ASSIGN                                                   !5, ~13
   11    16        INIT_FCALL                                               'rand'
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $15     
         20      > JMPZ                                                     $15, ->25
   12    21    >   INIT_FCALL                                               'strtoupper'
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !5, $16
   14    25    >   ASSIGN_OP                                     8          !3, !5
    9    26    >   POST_DEC                                         ~19     !0
         27      > JMPNZ                                                    ~19, ->10
   16    28    > > RETURN                                                   !3
   17    29*     > RETURN                                                   null

End of function randomstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.61 ms | 1394 KiB | 18 Q