3v4l.org

run code in 500+ 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 = 6, Position 2 = 18
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/5bUMS
function name:  (null)
number of ops:  39
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        FRAMELESS_ICALL_1                class_exists        ~3      'IntlChar'
          5      > JMPZ_EX                                              ~3      ~3, ->18
          6    >   INIT_FCALL                                                   'printf'
          7        SEND_VAL                                                     'U%2B%25X+%25s%0A'
          8        INIT_STATIC_METHOD_CALL                                      'IntlChar', 'ord'
          9        SEND_VAR_EX                                                  !0
         10        DO_FCALL                                          0  $4      
         11        SEND_VAR                                                     $4
         12        INIT_STATIC_METHOD_CALL                                      'IntlChar', 'charName'
         13        SEND_VAR_EX                                                  !0
         14        DO_FCALL                                          0  $5      
         15        SEND_VAR                                                     $5
         16        DO_ICALL                                             $6      
         17        BOOL                                                 ~3      $6
   19    18    >   INIT_FCALL                                                   'str_split'
         19        INIT_FCALL                                                   'strtoupper'
         20        INIT_FCALL                                                   'bin2hex'
         21        SEND_VAR                                                     !0
         22        DO_ICALL                                             $7      
         23        SEND_VAR                                                     $7
         24        DO_ICALL                                             $8      
         25        SEND_VAR                                                     $8
         26        SEND_VAL                                                     2
         27        DO_ICALL                                             $9      
         28        FRAMELESS_ICALL_2                implode             ~10     '%5Cx', $9
         29        CONCAT                                               ~11     '%5Cx', ~10
         30        ECHO                                                         ~11
         31        ECHO                                                         '%0A'
   20    32        INIT_FCALL                                                   'addcslashes'
         33        SEND_VAR                                                     !0
         34        SEND_VAL                                                     '%7F..%FF'
         35        DO_ICALL                                             $12     
         36        ECHO                                                         $12
         37        ECHO                                                         '%0A'
         38      > 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:  14
compiled vars:  !0 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
   12     1        INIT_FCALL                                                   'urldecode'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
    9     4        FRAMELESS_ICALL_3                preg_replace        ~2      '%2F%25u%28%5B0-9a-f%5D%7B3%2C4%7D%29%2Fi', '%26%23x%5C1%3B'
   12     5        OP_DATA                                                      $1
    9     6        ASSIGN                                                       !0, ~2
   14     7        INIT_FCALL                                                   'html_entity_decode'
          8        SEND_VAR                                                     !0
          9        SEND_VAL                                                     16
         10        SEND_VAL                                                     'UTF-8'
         11        DO_ICALL                                             $4      
         12      > RETURN                                                       $4
   15    13*     > RETURN                                                       null

End of function utf8_urldecode

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.26 ms | 3352 KiB | 27 Q