3v4l.org

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

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

End of function base64_decode_url

Generated using Vulcan Logic Dumper, using php 7.3.0