3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRandomString($n) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=+/'; $randomString = ''; for ($i = 0; $i < $n; $i++) { $index = rand(0, strlen($characters) - 1); $randomString .= $characters[$index]; } return $randomString; } foreach (['foo', 'bar', getRandomString(100), getRandomString(2000), '', getRandomString(2000)] as $data) { $hash = base64_encode(hash('sha256', $data, TRUE)); print base64_encode(hash('sha256', $data, TRUE)) . ' : '; // Modify the hash so it's safe to use in URLs. $hashed = str_replace(['+', '/', '='], ['-', '_', ''], $hash); print $hashed . ' : '; print strlen($hashed) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 48
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 48
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/AhYfp
function name:  (null)
number of ops:  50
compiled vars:  !0 = $data, !1 = $hash, !2 = $hashed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_ARRAY                                       ~3      'foo'
          1        ADD_ARRAY_ELEMENT                                ~3      'bar'
          2        INIT_FCALL                                               'getrandomstring'
          3        SEND_VAL                                                 100
          4        DO_FCALL                                      0  $4      
          5        ADD_ARRAY_ELEMENT                                ~3      $4
          6        INIT_FCALL                                               'getrandomstring'
          7        SEND_VAL                                                 2000
          8        DO_FCALL                                      0  $5      
          9        ADD_ARRAY_ELEMENT                                ~3      $5
         10        ADD_ARRAY_ELEMENT                                ~3      ''
         11        INIT_FCALL                                               'getrandomstring'
         12        SEND_VAL                                                 2000
         13        DO_FCALL                                      0  $6      
         14        ADD_ARRAY_ELEMENT                                ~3      $6
         15      > FE_RESET_R                                       $7      ~3, ->48
         16    > > FE_FETCH_R                                               $7, !0, ->48
   20    17    >   INIT_FCALL                                               'base64_encode'
         18        INIT_FCALL                                               'hash'
         19        SEND_VAL                                                 'sha256'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                         $9      
         25        ASSIGN                                                   !1, $9
   21    26        INIT_FCALL                                               'base64_encode'
         27        INIT_FCALL                                               'hash'
         28        SEND_VAL                                                 'sha256'
         29        SEND_VAR                                                 !0
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $11     
         32        SEND_VAR                                                 $11
         33        DO_ICALL                                         $12     
         34        CONCAT                                           ~13     $12, '+%3A+'
         35        ECHO                                                     ~13
   24    36        INIT_FCALL                                               'str_replace'
         37        SEND_VAL                                                 <array>
         38        SEND_VAL                                                 <array>
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                         $14     
         41        ASSIGN                                                   !2, $14
   25    42        CONCAT                                           ~16     !2, '+%3A+'
         43        ECHO                                                     ~16
   27    44        STRLEN                                           ~17     !2
         45        CONCAT                                           ~18     ~17, '%0A'
         46        ECHO                                                     ~18
   18    47      > JMP                                                      ->16
         48    >   FE_FREE                                                  $7
   28    49      > RETURN                                                   1

Function getrandomstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
Branch analysis from position: 5
filename:       /in/AhYfp
function name:  getRandomString
number of ops:  19
compiled vars:  !0 = $n, !1 = $characters, !2 = $randomString, !3 = $i, !4 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%3D%2B%2F'
    7     2        ASSIGN                                                   !2, ''
    9     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->15
   10     5    >   INIT_FCALL                                               'rand'
          6        SEND_VAL                                                 0
          7        STRLEN                                           ~8      !1
          8        SUB                                              ~9      ~8, 1
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !4, $10
   11    12        FETCH_DIM_R                                      ~12     !1, !4
         13        ASSIGN_OP                                     8          !2, ~12
    9    14        PRE_INC                                                  !3
         15    >   IS_SMALLER                                               !3, !0
         16      > JMPNZ                                                    ~15, ->5
   14    17    > > RETURN                                                   !2
   15    18*     > RETURN                                                   null

End of function getrandomstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.44 ms | 995 KiB | 20 Q