3v4l.org

run code in 500+ PHP versions simultaneously
<?php function seededDraws(): array { $list = [1, 2, 3, 4, 5, 6, 7, 8]; shuffle($list); return [mt_rand(), rand(), str_shuffle('abcdefgh'), array_rand(range(0, 99)), $list]; } mt_srand(42); $first = seededDraws(); mt_srand(42); echo 'mt_rand/rand/shuffle/str_shuffle/array_rand repeat after mt_srand(): ', var_export($first === seededDraws(), true), "\n"; mt_srand(42); $first = [random_int(0, PHP_INT_MAX), bin2hex(random_bytes(8))]; mt_srand(42); echo 'random_int/random_bytes repeat after mt_srand(): ', var_export($first === [random_int(0, PHP_INT_MAX), bin2hex(random_bytes(8))], true), "\n"; mt_srand(1); $plain = [mt_rand(), mt_rand()]; mt_srand(1); $withCsprng = [mt_rand()]; random_int(0, 9); random_bytes(4); $withCsprng[] = mt_rand(); echo 'random_int/random_bytes between two mt_rand() calls leave the sequence as it is: ', var_export($plain === $withCsprng, true), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VWnL
function name:  (null)
number of ops:  95
compiled vars:  !0 = $first, !1 = $plain, !2 = $withCsprng
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                                   'mt_srand'
          1        SEND_VAL                                                     42
          2        DO_ICALL                                                     
   12     3        INIT_FCALL                                                   'seededdraws'
          4        DO_FCALL                                          0  $4      
          5        ASSIGN                                                       !0, $4
   13     6        INIT_FCALL                                                   'mt_srand'
          7        SEND_VAL                                                     42
          8        DO_ICALL                                                     
   14     9        ECHO                                                         'mt_rand%2Frand%2Fshuffle%2Fstr_shuffle%2Farray_rand+repeat+after+mt_srand%28%29%3A+'
         10        INIT_FCALL                                                   'var_export'
         11        INIT_FCALL                                                   'seededdraws'
         12        DO_FCALL                                          0  $7      
         13        IS_IDENTICAL                                         ~8      !0, $7
         14        SEND_VAL                                                     ~8
         15        SEND_VAL                                                     <true>
         16        DO_ICALL                                             $9      
         17        ECHO                                                         $9
         18        ECHO                                                         '%0A'
   16    19        INIT_FCALL                                                   'mt_srand'
         20        SEND_VAL                                                     42
         21        DO_ICALL                                                     
   17    22        INIT_FCALL                                                   'random_int'
         23        SEND_VAL                                                     0
         24        SEND_VAL                                                     9223372036854775807
         25        DO_ICALL                                             $11     
         26        INIT_ARRAY                                           ~12     $11
         27        INIT_FCALL                                                   'bin2hex'
         28        INIT_FCALL                                                   'random_bytes'
         29        SEND_VAL                                                     8
         30        DO_ICALL                                             $13     
         31        SEND_VAR                                                     $13
         32        DO_ICALL                                             $14     
         33        ADD_ARRAY_ELEMENT                                    ~12     $14
         34        ASSIGN                                                       !0, ~12
   18    35        INIT_FCALL                                                   'mt_srand'
         36        SEND_VAL                                                     42
         37        DO_ICALL                                                     
   19    38        ECHO                                                         'random_int%2Frandom_bytes+repeat+after+mt_srand%28%29%3A+'
         39        INIT_FCALL                                                   'var_export'
         40        INIT_FCALL                                                   'random_int'
         41        SEND_VAL                                                     0
         42        SEND_VAL                                                     9223372036854775807
         43        DO_ICALL                                             $17     
         44        INIT_ARRAY                                           ~18     $17
         45        INIT_FCALL                                                   'bin2hex'
         46        INIT_FCALL                                                   'random_bytes'
         47        SEND_VAL                                                     8
         48        DO_ICALL                                             $19     
         49        SEND_VAR                                                     $19
         50        DO_ICALL                                             $20     
         51        ADD_ARRAY_ELEMENT                                    ~18     $20
         52        IS_IDENTICAL                                         ~21     !0, ~18
         53        SEND_VAL                                                     ~21
         54        SEND_VAL                                                     <true>
         55        DO_ICALL                                             $22     
         56        ECHO                                                         $22
         57        ECHO                                                         '%0A'
   21    58        INIT_FCALL                                                   'mt_srand'
         59        SEND_VAL                                                     1
         60        DO_ICALL                                                     
   22    61        INIT_FCALL                                                   'mt_rand'
         62        DO_ICALL                                             $24     
         63        INIT_ARRAY                                           ~25     $24
         64        INIT_FCALL                                                   'mt_rand'
         65        DO_ICALL                                             $26     
         66        ADD_ARRAY_ELEMENT                                    ~25     $26
         67        ASSIGN                                                       !1, ~25
   23    68        INIT_FCALL                                                   'mt_srand'
         69        SEND_VAL                                                     1
         70        DO_ICALL                                                     
   24    71        INIT_FCALL                                                   'mt_rand'
         72        DO_ICALL                                             $29     
         73        INIT_ARRAY                                           ~30     $29
         74        ASSIGN                                                       !2, ~30
   25    75        INIT_FCALL                                                   'random_int'
         76        SEND_VAL                                                     0
         77        SEND_VAL                                                     9
         78        DO_ICALL                                                     
   26    79        INIT_FCALL                                                   'random_bytes'
         80        SEND_VAL                                                     4
         81        DO_ICALL                                                     
   27    82        INIT_FCALL                                                   'mt_rand'
         83        DO_ICALL                                             $35     
         84        ASSIGN_DIM                                                   !2
         85        OP_DATA                                                      $35
   28    86        ECHO                                                         'random_int%2Frandom_bytes+between+two+mt_rand%28%29+calls+leave+the+sequence+as+it+is%3A+'
         87        INIT_FCALL                                                   'var_export'
         88        IS_IDENTICAL                                         ~36     !1, !2
         89        SEND_VAL                                                     ~36
         90        SEND_VAL                                                     <true>
         91        DO_ICALL                                             $37     
         92        ECHO                                                         $37
         93        ECHO                                                         '%0A'
         94      > RETURN                                                       1

Function seededdraws:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VWnL
function name:  seededDraws
number of ops:  27
compiled vars:  !0 = $list
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, <array>
    6     1        INIT_FCALL                                                   'shuffle'
          2        SEND_REF                                                     !0
          3        DO_ICALL                                                     
    8     4        INIT_FCALL                                                   'mt_rand'
          5        DO_ICALL                                             $3      
          6        INIT_ARRAY                                           ~4      $3
          7        INIT_FCALL                                                   'rand'
          8        DO_ICALL                                             $5      
          9        ADD_ARRAY_ELEMENT                                    ~4      $5
         10        INIT_FCALL                                                   'str_shuffle'
         11        SEND_VAL                                                     'abcdefgh'
         12        DO_ICALL                                             $6      
         13        ADD_ARRAY_ELEMENT                                    ~4      $6
         14        INIT_FCALL                                                   'array_rand'
         15        INIT_FCALL                                                   'range'
         16        SEND_VAL                                                     0
         17        SEND_VAL                                                     99
         18        DO_ICALL                                             $7      
         19        SEND_VAR                                                     $7
         20        DO_ICALL                                             $8      
         21        ADD_ARRAY_ELEMENT                                    ~4      $8
         22        ADD_ARRAY_ELEMENT                                    ~4      !0
         23        VERIFY_RETURN_TYPE                                           ~4
         24      > RETURN                                                       ~4
    9    25*       VERIFY_RETURN_TYPE                                           
         26*     > RETURN                                                       null

End of function seededdraws

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
134.51 ms | 509 KiB | 22 Q