3v4l.org

run code in 500+ PHP versions simultaneously
<?php // https://www.strangebuzz.com/en/snippets/convert-a-string-into-an-array-of-characters $tokenSize = 32; try { $random = random_bytes($tokenSize); } catch (\Exception $e) { throw new \RuntimeException('Unable to get random_bytes.'); } $base = base64_encode($random); $clean = str_replace(str_split('+/-_'), '', $base); $cut = substr($clean, 0, $tokenSize); echo 'Token: '.$cut."\n"; echo 'Token length: '.strlen($cut);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/vn6so
function name:  (null)
number of ops:  31
compiled vars:  !0 = $tokenSize, !1 = $random, !2 = $e, !3 = $base, !4 = $clean, !5 = $cut
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, 32
    7     1        INIT_FCALL                                                   'random_bytes'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $7      
          4        ASSIGN                                                       !1, $7
          5      > JMP                                                          ->11
    8     6  E > > CATCH                                           last         'Exception'
    9     7    >   NEW                                                  $9      'RuntimeException'
          8        SEND_VAL_EX                                                  'Unable+to+get+random_bytes.'
          9        DO_FCALL                                          0          
         10      > THROW                                             0          $9
   11    11    >   INIT_FCALL                                                   'base64_encode'
         12        SEND_VAR                                                     !1
         13        DO_ICALL                                             $11     
         14        ASSIGN                                                       !3, $11
   12    15        INIT_FCALL                                                   'str_split'
         16        SEND_VAL                                                     '%2B%2F-_'
         17        DO_ICALL                                             $13     
         18        FRAMELESS_ICALL_3                str_replace         ~14     $13, ''
         19        OP_DATA                                                      !3
         20        ASSIGN                                                       !4, ~14
   13    21        FRAMELESS_ICALL_3                substr              ~16     !4, 0
         22        OP_DATA                                                      !0
         23        ASSIGN                                                       !5, ~16
   15    24        CONCAT                                               ~18     'Token%3A+', !5
         25        CONCAT                                               ~19     ~18, '%0A'
         26        ECHO                                                         ~19
   16    27        STRLEN                                               ~20     !5
         28        CONCAT                                               ~21     'Token+length%3A+', ~20
         29        ECHO                                                         ~21
         30      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.69 ms | 1303 KiB | 16 Q