3v4l.org

run code in 300+ PHP versions simultaneously
<?php mt_srand(42); for ($i = 0; $i < 20; $i++) { $key = generate_key(); $len = count($key); echo "{$key} {$len}\n"; } function generate_key() { return base64_urlencode(rand_buffer(48)); } function base64_urlencode($buf) { return str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode($buf)); } function rand_buffer($n) { // return openssl_random_pseudo_bytes($n); $buf = ""; for ($i = 0; $i < $n; $i++) { $buf .= chr(mt_rand(0, 255)); } return $buf; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
Branch analysis from position: 5
filename:       /in/S2reI
function name:  (null)
number of ops:  19
compiled vars:  !0 = $i, !1 = $key, !2 = $len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'mt_srand'
          1        SEND_VAL                                                 42
          2        DO_ICALL                                                 
    5     3        ASSIGN                                                   !0, 0
          4      > JMP                                                      ->16
    6     5    >   INIT_FCALL_BY_NAME                                       'generate_key'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
    7     8        COUNT                                            ~7      !1
          9        ASSIGN                                                   !2, ~7
    8    10        ROPE_INIT                                     4  ~10     !1
         11        ROPE_ADD                                      1  ~10     ~10, '+'
         12        ROPE_ADD                                      2  ~10     ~10, !2
         13        ROPE_END                                      3  ~9      ~10, '%0A'
         14        ECHO                                                     ~9
    5    15        PRE_INC                                                  !0
         16    >   IS_SMALLER                                               !0, 20
         17      > JMPNZ                                                    ~13, ->5
   26    18    > > RETURN                                                   1

Function generate_key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S2reI
function name:  generate_key
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL_BY_NAME                                       'base64_urlencode'
          1        INIT_FCALL_BY_NAME                                       'rand_buffer'
          2        SEND_VAL_EX                                              48
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR_NO_REF_EX                                       $0
          5        DO_FCALL                                      0  $1      
          6      > RETURN                                                   $1
   13     7*     > RETURN                                                   null

End of function generate_key

Function base64_urlencode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S2reI
function name:  base64_urlencode
number of ops:  11
compiled vars:  !0 = $buf
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        INIT_FCALL                                               'base64_encode'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9      > RETURN                                                   $2
   17    10*     > RETURN                                                   null

End of function base64_urlencode

Function rand_buffer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 4
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 4
Branch analysis from position: 15
Branch analysis from position: 4
filename:       /in/S2reI
function name:  rand_buffer
number of ops:  17
compiled vars:  !0 = $n, !1 = $buf, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        ASSIGN                                                   !1, ''
   22     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->13
   23     4    >   INIT_FCALL                                               'chr'
          5        INIT_FCALL                                               'mt_rand'
          6        SEND_VAL                                                 0
          7        SEND_VAL                                                 255
          8        DO_ICALL                                         $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                         $6      
         11        ASSIGN_OP                                     8          !1, $6
   22    12        PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !0
         14      > JMPNZ                                                    ~9, ->4
   25    15    > > RETURN                                                   !1
   26    16*     > RETURN                                                   null

End of function rand_buffer

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.92 ms | 1392 KiB | 23 Q