3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @link https://stackoverflow.com/a/10042586/367456 * @param string $string unicode and ulrencoded string * @return string decoded string */ function utf8_urldecode($string) { $string = preg_replace( "/%u([0-9a-f]{3,4})/i", "&#x\\1;", urldecode($string) ); return html_entity_decode($string, ENT_XML1, 'UTF-8'); } $decoded = utf8_urldecode('%u20AC'); class_exists('IntlChar') && printf("U+%X %s\n", IntlChar::ord($decoded), IntlChar::charName($decoded)); echo "\\x" . implode("\\x", str_split(strtoupper(bin2hex($decoded)), 2)), "\n"; echo addcslashes($decoded, "\x7F..\xFF"), "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/5bUMS
function name:  (null)
number of ops:  44
compiled vars:  !0 = $decoded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'utf8_urldecode'
          1        SEND_VAL                                                 '%25u20AC'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   18     4        INIT_FCALL                                               'class_exists'
          5        SEND_VAL                                                 'IntlChar'
          6        DO_ICALL                                         $3      
          7      > JMPZ_EX                                          ~4      $3, ->20
          8    >   INIT_FCALL                                               'printf'
          9        SEND_VAL                                                 'U%2B%25X+%25s%0A'
         10        INIT_STATIC_METHOD_CALL                                  'IntlChar', 'ord'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR                                                 $5
         14        INIT_STATIC_METHOD_CALL                                  'IntlChar', 'charName'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                         $7      
         19        BOOL                                             ~4      $7
   19    20    >   INIT_FCALL                                               'implode'
         21        SEND_VAL                                                 '%5Cx'
         22        INIT_FCALL                                               'str_split'
         23        INIT_FCALL                                               'strtoupper'
         24        INIT_FCALL                                               'bin2hex'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $8      
         27        SEND_VAR                                                 $8
         28        DO_ICALL                                         $9      
         29        SEND_VAR                                                 $9
         30        SEND_VAL                                                 2
         31        DO_ICALL                                         $10     
         32        SEND_VAR                                                 $10
         33        DO_ICALL                                         $11     
         34        CONCAT                                           ~12     '%5Cx', $11
         35        ECHO                                                     ~12
         36        ECHO                                                     '%0A'
   20    37        INIT_FCALL                                               'addcslashes'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 '%7F..%FF'
         40        DO_ICALL                                         $13     
         41        ECHO                                                     $13
         42        ECHO                                                     '%0A'
         43      > RETURN                                                   1

Function utf8_urldecode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5bUMS
function name:  utf8_urldecode
number of ops:  17
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'preg_replace'
   10     2        SEND_VAL                                                 '%2F%25u%28%5B0-9a-f%5D%7B3%2C4%7D%29%2Fi'
   11     3        SEND_VAL                                                 '%26%23x%5C1%3B'
   12     4        INIT_FCALL                                               'urldecode'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
    9     8        DO_ICALL                                         $2      
          9        ASSIGN                                                   !0, $2
   14    10        INIT_FCALL                                               'html_entity_decode'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 16
         13        SEND_VAL                                                 'UTF-8'
         14        DO_ICALL                                         $4      
         15      > RETURN                                                   $4
   15    16*     > RETURN                                                   null

End of function utf8_urldecode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
262.66 ms | 1019 KiB | 24 Q