3v4l.org

run code in 500+ PHP versions simultaneously
<?php $strs = [ 'Ostroměr', 'Šventaragis', 'Świętopełk', 'Dušan', 'Živko', ]; /** * Decodes a url-encoded path segment. */ function decodePathSegment(string $path): string { $path = rawurldecode($path); $encoding = mb_detect_encoding($path, ['UTF-8', 'ISO-8859-1']); switch ($encoding) { case 'ISO-8859-1': $path = utf8_encode($path); } return $path; } foreach($strs as $str) { var_dump( decodePathSegment($str)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/RrjlE
function name:  (null)
number of ops:  12
compiled vars:  !0 = $strs, !1 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   25     1      > FE_RESET_R                                           $3      !0, ->10
          2    > > FE_FETCH_R                                                   $3, !1, ->10
   26     3    >   INIT_FCALL                                                   'var_dump'
   27     4        INIT_FCALL                                                   'decodepathsegment'
          5        SEND_VAR                                                     !1
          6        DO_FCALL                                          0  $4      
          7        SEND_VAR                                                     $4
   26     8        DO_ICALL                                                     
   25     9      > JMP                                                          ->2
         10    >   FE_FREE                                                      $3
   28    11      > RETURN                                                       1

Function decodepathsegment:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RrjlE
function name:  decodePathSegment
number of ops:  21
compiled vars:  !0 = $path, !1 = $encoding
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   15     1        INIT_FCALL                                                   'rawurldecode'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $2      
          4        ASSIGN                                                       !0, $2
   16     5        INIT_FCALL                                                   'mb_detect_encoding'
          6        SEND_VAR                                                     !0
          7        SEND_VAL                                                     <array>
          8        DO_ICALL                                             $4      
          9        ASSIGN                                                       !1, $4
   19    10        IS_EQUAL                                                     !1, 'ISO-8859-1'
         11      > JMPNZ                                                        ~6, ->13
         12    > > JMP                                                          ->17
   20    13    >   INIT_FCALL                                                   'utf8_encode'
         14        SEND_VAR                                                     !0
         15        DO_FCALL_BY_NAME                                             
         16        ASSIGN                                                       !0, $7
   23    17    >   VERIFY_RETURN_TYPE                                           !0
         18      > RETURN                                                       !0
   24    19*       VERIFY_RETURN_TYPE                                           
         20*     > RETURN                                                       null

End of function decodepathsegment

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
222.58 ms | 1957 KiB | 18 Q