3v4l.org

run code in 500+ PHP versions simultaneously
<?php function _random(string $set , int $length): string { $setLength = strlen($set); $randomKey = random_int(0, $setLength - 1); $firstPiece = substr($set, 0, $randomKey); $secondPiece = substr($set, $randomKey, $setLength - $randomKey); $removedCharacter = $firstPiece[strlen($firstPiece) - 1] ?? null; if(null === $removedCharacter || $length === 0) { return ''; } $firstPieceWithoutTheLastChar = substr($firstPiece, 0, -1); return $removedCharacter . _random($firstPieceWithoutTheLastChar . $secondPiece, $length - 1); } $a = _random('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 32); $b = _random('abcdefghijklmnopqrstuvwxyz', 8); $c = _random('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 64); var_dump($a, $b, $c);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aXaJ6
function name:  (null)
number of ops:  21
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                                   '_random'
          1        SEND_VAL                                                     'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
          2        SEND_VAL                                                     32
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !0, $3
   23     5        INIT_FCALL                                                   '_random'
          6        SEND_VAL                                                     'abcdefghijklmnopqrstuvwxyz'
          7        SEND_VAL                                                     8
          8        DO_FCALL                                          0  $5      
          9        ASSIGN                                                       !1, $5
   24    10        INIT_FCALL                                                   '_random'
         11        SEND_VAL                                                     'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
         12        SEND_VAL                                                     64
         13        DO_FCALL                                          0  $7      
         14        ASSIGN                                                       !2, $7
   25    15        INIT_FCALL                                                   'var_dump'
         16        SEND_VAR                                                     !0
         17        SEND_VAR                                                     !1
         18        SEND_VAR                                                     !2
         19        DO_ICALL                                                     
         20      > RETURN                                                       1

Function _random:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/aXaJ6
function name:  _random
number of ops:  43
compiled vars:  !0 = $set, !1 = $length, !2 = $setLength, !3 = $randomKey, !4 = $firstPiece, !5 = $secondPiece, !6 = $removedCharacter, !7 = $firstPieceWithoutTheLastChar
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    6     2        STRLEN                                               ~8      !0
          3        ASSIGN                                                       !2, ~8
    7     4        INIT_FCALL                                                   'random_int'
          5        SEND_VAL                                                     0
          6        SUB                                                  ~10     !2, 1
          7        SEND_VAL                                                     ~10
          8        DO_ICALL                                             $11     
          9        ASSIGN                                                       !3, $11
    9    10        FRAMELESS_ICALL_3                substr              ~13     !0, 0
         11        OP_DATA                                                      !3
         12        ASSIGN                                                       !4, ~13
   10    13        SUB                                                  ~15     !2, !3
         14        FRAMELESS_ICALL_3                substr              ~16     !0, !3
         15        OP_DATA                                                      ~15
         16        ASSIGN                                                       !5, ~16
   12    17        STRLEN                                               ~18     !4
         18        SUB                                                  ~19     ~18, 1
         19        FETCH_DIM_IS                                         ~20     !4, ~19
         20        COALESCE                                             ~21     ~20
         21        QM_ASSIGN                                            ~21     null
         22        ASSIGN                                                       !6, ~21
   13    23        TYPE_CHECK                                        2  ~23     !6
         24      > JMPNZ_EX                                             ~23     ~23, ->27
         25    >   IS_IDENTICAL                                         ~24     !1, 0
         26        BOOL                                                 ~23     ~24
         27    > > JMPZ                                                         ~23, ->29
   14    28    > > RETURN                                                       ''
   16    29    >   FRAMELESS_ICALL_3                substr              ~25     !4, 0
         30        OP_DATA                                                      -1
         31        ASSIGN                                                       !7, ~25
   18    32        INIT_FCALL_BY_NAME                                           '_random'
         33        CONCAT                                               ~27     !7, !5
         34        SEND_VAL_EX                                                  ~27
         35        SUB                                                  ~28     !1, 1
         36        SEND_VAL_EX                                                  ~28
         37        DO_FCALL                                          0  $29     
         38        CONCAT                                               ~30     !6, $29
         39        VERIFY_RETURN_TYPE                                           ~30
         40      > RETURN                                                       ~30
   19    41*       VERIFY_RETURN_TYPE                                           
         42*     > RETURN                                                       null

End of function _random

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.06 ms | 1387 KiB | 18 Q