3v4l.org

run code in 300+ PHP versions simultaneously
<?php function a($strUrl) { $strUrl = explode('/', $strUrl, 4); $strUrl[3] = rawurlencode($strUrl[3]); $strUrl[3] = str_replace(array('%2F', '%3F', '%3D', '%26', '%25'), array('/', '?', '=', '&', '%'), $strUrl[3]); $strUrl = implode('/', $strUrl); $strUrl = str_replace('&', '&amp;', $strUrl); return $strUrl; } function b($strUrl) { return htmlspecialchars($strUrl, ENT_XML1, 'UTF-8'); } $urls = array( 'http://www.example.com/', 'http://www.example.com/alias', 'http://www.example.com/alias.html', 'http://www.example.com/alias/page?foo=bar', 'http://www.example.com/alias?foo=bar&bar=foo', 'http://www.example.com:8080/alias', 'http://www.example.com:8080/alias?foo=bar&bar[bar]=foo', 'http://www.example.com/älias', ); foreach ($urls as $url) { if (a($url) === b($url)) { echo "✓\n"; echo $url."\n"; } else { echo "✘\n"; echo $url."\n"; echo a($url)."\n"; echo b($url)."\n"; } echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 30
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/g7cZJ
function name:  (null)
number of ops:  32
compiled vars:  !0 = $urls, !1 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   28     1      > FE_RESET_R                                       $3      !0, ->30
          2    > > FE_FETCH_R                                               $3, !1, ->30
   29     3    >   INIT_FCALL                                               'a'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        INIT_FCALL                                               'b'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $5      
          9        IS_IDENTICAL                                             $4, $5
         10      > JMPZ                                                     ~6, ->15
   30    11    >   ECHO                                                     '%E2%9C%93%0A'
   31    12        CONCAT                                           ~7      !1, '%0A'
         13        ECHO                                                     ~7
         14      > JMP                                                      ->28
   33    15    >   ECHO                                                     '%E2%9C%98%0A'
   34    16        CONCAT                                           ~8      !1, '%0A'
         17        ECHO                                                     ~8
   35    18        INIT_FCALL                                               'a'
         19        SEND_VAR                                                 !1
         20        DO_FCALL                                      0  $9      
         21        CONCAT                                           ~10     $9, '%0A'
         22        ECHO                                                     ~10
   36    23        INIT_FCALL                                               'b'
         24        SEND_VAR                                                 !1
         25        DO_FCALL                                      0  $11     
         26        CONCAT                                           ~12     $11, '%0A'
         27        ECHO                                                     ~12
   39    28    >   ECHO                                                     '%0A'
   28    29      > JMP                                                      ->2
         30    >   FE_FREE                                                  $3
   40    31      > RETURN                                                   1

Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g7cZJ
function name:  a
number of ops:  34
compiled vars:  !0 = $strUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2F'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 4
          5        DO_ICALL                                         $1      
          6        ASSIGN                                                   !0, $1
    5     7        INIT_FCALL                                               'rawurlencode'
          8        FETCH_DIM_R                                      ~4      !0, 3
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        ASSIGN_DIM                                               !0, 3
         12        OP_DATA                                                  $5
    6    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <array>
         16        FETCH_DIM_R                                      ~7      !0, 3
         17        SEND_VAL                                                 ~7
         18        DO_ICALL                                         $8      
         19        ASSIGN_DIM                                               !0, 3
         20        OP_DATA                                                  $8
    7    21        INIT_FCALL                                               'implode'
         22        SEND_VAL                                                 '%2F'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $9      
         25        ASSIGN                                                   !0, $9
    8    26        INIT_FCALL                                               'str_replace'
         27        SEND_VAL                                                 '%26'
         28        SEND_VAL                                                 '%26amp%3B'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $11     
         31        ASSIGN                                                   !0, $11
   10    32      > RETURN                                                   !0
   11    33*     > RETURN                                                   null

End of function a

Function b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g7cZJ
function name:  b
number of ops:  8
compiled vars:  !0 = $strUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'htmlspecialchars'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 16
          4        SEND_VAL                                                 'UTF-8'
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   15     7*     > RETURN                                                   null

End of function b

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.71 ms | 1403 KiB | 27 Q