3v4l.org

run code in 300+ PHP versions simultaneously
<?php function base64_encode_url($string) { $data = base64_encode($string); return str_replace(['+','/','='], ['-','_',''], $data); } function base64_decode_url($string) { $data = str_replace(['-','_'], ['+','/'], $string); $mod4 = strlen($data) % 4; return base64_decode($data /*. substr('====', $mod4)*/); } for ($i=0; $i<20000; $i++) { $data = random_bytes(rand(12,20)); if (base64_decode_url(base64_encode($data)) !== $data) { echo "FAIL"; } } echo "OK";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 2
Branch analysis from position: 22
Branch analysis from position: 2
Branch analysis from position: 19
filename:       /in/9TR6J
function name:  (null)
number of ops:  24
compiled vars:  !0 = $i, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->20
   15     2    >   INIT_FCALL                                               'random_bytes'
          3        INIT_FCALL                                               'rand'
          4        SEND_VAL                                                 12
          5        SEND_VAL                                                 20
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !1, $4
   16    10        INIT_FCALL                                               'base64_decode_url'
         11        INIT_FCALL                                               'base64_encode'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
         15        DO_FCALL                                      0  $7      
         16        IS_NOT_IDENTICAL                                         !1, $7
         17      > JMPZ                                                     ~8, ->19
   17    18    >   ECHO                                                     'FAIL'
   14    19    >   PRE_INC                                                  !0
         20    >   IS_SMALLER                                               !0, 20000
         21      > JMPNZ                                                    ~10, ->2
   21    22    >   ECHO                                                     'OK'
         23      > RETURN                                                   1

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

End of function base64_encode_url

Function base64_decode_url:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9TR6J
function name:  base64_decode_url
number of ops:  15
compiled vars:  !0 = $string, !1 = $data, !2 = $mod4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   10     7        STRLEN                                           ~5      !1
          8        MOD                                              ~6      ~5, 4
          9        ASSIGN                                                   !2, ~6
   11    10        INIT_FCALL                                               'base64_decode'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $8      
         13      > RETURN                                                   $8
   12    14*     > RETURN                                                   null

End of function base64_decode_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.11 ms | 1403 KiB | 24 Q