3v4l.org

run code in 300+ PHP versions simultaneously
<?php class utils { public static function replace_unicode_escape_sequence($str) { return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'iso-8859-1', 'UCS-2BE'); }, $str); } } header('Content-Type: text/plain; charset=iso-8859-1'); $strs = 'F\u00f6retag: Betalning'; /*echo utils::replace_unicode_escape_sequence($str);*/ function unicode_escape_sequences($str){ $working = json_encode($str); $working = preg_replace('/\\\u([0-9a-z]{4})/', '&#x$1;', $working); return json_decode($working); } echo unicode_escape_sequences($strs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2B3ob
function name:  (null)
number of ops:  9
compiled vars:  !0 = $strs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'header'
          1        SEND_VAL                                                 'Content-Type%3A+text%2Fplain%3B+charset%3Diso-8859-1'
          2        DO_ICALL                                                 
   15     3        ASSIGN                                                   !0, 'F%5Cu00f6retag%3A+Betalning'
   23     4        INIT_FCALL                                               'unicode_escape_sequences'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $3      
          7        ECHO                                                     $3
          8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F2B3ob%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2B3ob
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'mb_convert_encoding'
          2        INIT_FCALL                                               'pack'
          3        SEND_VAL                                                 'H%2A'
          4        FETCH_DIM_R                                      ~1      !0, 1
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        SEND_VAL                                                 'iso-8859-1'
          9        SEND_VAL                                                 'UCS-2BE'
         10        DO_ICALL                                         $3      
         11      > RETURN                                                   $3
    7    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F2B3ob%3A5%240

Function unicode_escape_sequences:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2B3ob
function name:  unicode_escape_sequences
number of ops:  16
compiled vars:  !0 = $str, !1 = $working
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'json_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
          5        INIT_FCALL                                               'preg_replace'
          6        SEND_VAL                                                 '%2F%5C%5Cu%28%5B0-9a-z%5D%7B4%7D%29%2F'
          7        SEND_VAL                                                 '%26%23x%241%3B'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !1, $4
         11        INIT_FCALL                                               'json_decode'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14      > RETURN                                                   $6
         15*     > RETURN                                                   null

End of function unicode_escape_sequences

Class utils:
Function replace_unicode_escape_sequence:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2B3ob
function name:  replace_unicode_escape_sequence
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%2F%5C%5Cu%28%5B0-9a-f%5D%7B4%7D%29%2Fi'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F2B3ob%3A5%240'
    7     4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    8     8*     > RETURN                                                   null

End of function replace_unicode_escape_sequence

End of class utils.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.44 ms | 1402 KiB | 28 Q