3v4l.org

run code in 300+ PHP versions simultaneously
<?php function random_password(int $min, int $max) { $allowed = array_merge( [33, 60, 62, 94, 95], range(48, 57), range(64, 90), range(97, 122) ); $length = random_int($min, $max); $chars = []; for ($i = 0; $i < $length; $i++) { $bi = random_int(0, count($allowed)-1); $chars[] = chr($allowed[$bi]); } return implode('', $chars); } var_dump(random_password(8, 12));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/thjqC
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'random_password'
          2        SEND_VAL                                                 8
          3        SEND_VAL                                                 12
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function random_password:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 29
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 29
Branch analysis from position: 45
Branch analysis from position: 29
filename:       /in/thjqC
function name:  random_password
number of ops:  51
compiled vars:  !0 = $min, !1 = $max, !2 = $allowed, !3 = $length, !4 = $chars, !5 = $i, !6 = $bi
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'array_merge'
    6     3        SEND_VAL                                                 <array>
    7     4        INIT_FCALL                                               'range'
          5        SEND_VAL                                                 48
          6        SEND_VAL                                                 57
          7        DO_ICALL                                         $7      
          8        SEND_VAR                                                 $7
    8     9        INIT_FCALL                                               'range'
         10        SEND_VAL                                                 64
         11        SEND_VAL                                                 90
         12        DO_ICALL                                         $8      
         13        SEND_VAR                                                 $8
    9    14        INIT_FCALL                                               'range'
         15        SEND_VAL                                                 97
         16        SEND_VAL                                                 122
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                         $10     
    5    20        ASSIGN                                                   !2, $10
   12    21        INIT_FCALL                                               'random_int'
         22        SEND_VAR                                                 !0
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $12     
         25        ASSIGN                                                   !3, $12
   14    26        ASSIGN                                                   !4, <array>
   16    27        ASSIGN                                                   !5, 0
         28      > JMP                                                      ->43
   17    29    >   INIT_FCALL                                               'random_int'
         30        SEND_VAL                                                 0
         31        COUNT                                            ~16     !2
         32        SUB                                              ~17     ~16, 1
         33        SEND_VAL                                                 ~17
         34        DO_ICALL                                         $18     
         35        ASSIGN                                                   !6, $18
   18    36        INIT_FCALL                                               'chr'
         37        FETCH_DIM_R                                      ~21     !2, !6
         38        SEND_VAL                                                 ~21
         39        DO_ICALL                                         $22     
         40        ASSIGN_DIM                                               !4
         41        OP_DATA                                                  $22
   16    42        PRE_INC                                                  !5
         43    >   IS_SMALLER                                               !5, !3
         44      > JMPNZ                                                    ~24, ->29
   21    45    >   INIT_FCALL                                               'implode'
         46        SEND_VAL                                                 ''
         47        SEND_VAR                                                 !4
         48        DO_ICALL                                         $25     
         49      > RETURN                                                   $25
   22    50*     > RETURN                                                   null

End of function random_password

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.07 ms | 1394 KiB | 26 Q