3v4l.org

run code in 300+ 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 = 31, Position 2 = 33
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/aXaJ6
function name:  _random
number of ops:  52
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        INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 0
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !4, $13
   10    16        INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !3
         19        SUB                                              ~15     !2, !3
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                         $16     
         22        ASSIGN                                                   !5, $16
   12    23        STRLEN                                           ~18     !4
         24        SUB                                              ~19     ~18, 1
         25        FETCH_DIM_IS                                     ~20     !4, ~19
         26        COALESCE                                         ~21     ~20
         27        QM_ASSIGN                                        ~21     null
         28        ASSIGN                                                   !6, ~21
   13    29        TYPE_CHECK                                    2  ~23     !6
         30      > JMPNZ_EX                                         ~23     ~23, ->33
         31    >   IS_IDENTICAL                                     ~24     !1, 0
         32        BOOL                                             ~23     ~24
         33    > > JMPZ                                                     ~23, ->35
   14    34    > > RETURN                                                   ''
   16    35    >   INIT_FCALL                                               'substr'
         36        SEND_VAR                                                 !4
         37        SEND_VAL                                                 0
         38        SEND_VAL                                                 -1
         39        DO_ICALL                                         $25     
         40        ASSIGN                                                   !7, $25
   18    41        INIT_FCALL_BY_NAME                                       '_random'
         42        CONCAT                                           ~27     !7, !5
         43        SEND_VAL_EX                                              ~27
         44        SUB                                              ~28     !1, 1
         45        SEND_VAL_EX                                              ~28
         46        DO_FCALL                                      0  $29     
         47        CONCAT                                           ~30     !6, $29
         48        VERIFY_RETURN_TYPE                                       ~30
         49      > RETURN                                                   ~30
   19    50*       VERIFY_RETURN_TYPE                                       
         51*     > RETURN                                                   null

End of function _random

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.73 ms | 1007 KiB | 19 Q