3v4l.org

run code in 300+ PHP versions simultaneously
<?php mb_regex_encoding('SJIS'); $string = "my number is 63735"; $pattern = "63735"; $packed = pack('n', "63735"); //before convert to ASCII: f8f7 var_dump(bin2hex($packed)); $replacement = mb_convert_encoding($packed, "SJIS", "ASCII"); //after convert to ASCII: 3f8180 var_dump(bin2hex($replacement)); //after converting back to SJIS: var_dump(bin2hex(mb_convert_encoding($replacement, "UTF-8", "SJIS"))); //expected result: my number is �� //OK $new_string = mb_ereg_replace($pattern, $replacement, $string); //expected result: my new number is �� //but it returns NULL. $ret = mb_ereg_replace("number", "new number", $new_string); var_dump($ret); var_dump(mb_convert_encoding($ret, "UTF-8", "SJIS"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JE5r8
function name:  (null)
number of ops:  63
compiled vars:  !0 = $string, !1 = $pattern, !2 = $packed, !3 = $replacement, !4 = $new_string, !5 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'mb_regex_encoding'
          1        SEND_VAL                                                 'SJIS'
          2        DO_ICALL                                                 
    3     3        ASSIGN                                                   !0, 'my+number+is+63735'
    4     4        ASSIGN                                                   !1, '63735'
    5     5        INIT_FCALL                                               'pack'
          6        SEND_VAL                                                 'n'
          7        SEND_VAL                                                 '63735'
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !2, $9
    7    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'bin2hex'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $11     
         14        SEND_VAR                                                 $11
         15        DO_ICALL                                                 
   10    16        INIT_FCALL                                               'mb_convert_encoding'
         17        SEND_VAR                                                 !2
         18        SEND_VAL                                                 'SJIS'
         19        SEND_VAL                                                 'ASCII'
         20        DO_ICALL                                         $13     
         21        ASSIGN                                                   !3, $13
   12    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'bin2hex'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                                 
   15    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'bin2hex'
         30        INIT_FCALL                                               'mb_convert_encoding'
         31        SEND_VAR                                                 !3
         32        SEND_VAL                                                 'UTF-8'
         33        SEND_VAL                                                 'SJIS'
         34        DO_ICALL                                         $17     
         35        SEND_VAR                                                 $17
         36        DO_ICALL                                         $18     
         37        SEND_VAR                                                 $18
         38        DO_ICALL                                                 
   20    39        INIT_FCALL                                               'mb_ereg_replace'
         40        SEND_VAR                                                 !1
         41        SEND_VAR                                                 !3
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                         $20     
         44        ASSIGN                                                   !4, $20
   24    45        INIT_FCALL                                               'mb_ereg_replace'
         46        SEND_VAL                                                 'number'
         47        SEND_VAL                                                 'new+number'
         48        SEND_VAR                                                 !4
         49        DO_ICALL                                         $22     
         50        ASSIGN                                                   !5, $22
   25    51        INIT_FCALL                                               'var_dump'
         52        SEND_VAR                                                 !5
         53        DO_ICALL                                                 
   26    54        INIT_FCALL                                               'var_dump'
         55        INIT_FCALL                                               'mb_convert_encoding'
         56        SEND_VAR                                                 !5
         57        SEND_VAL                                                 'UTF-8'
         58        SEND_VAL                                                 'SJIS'
         59        DO_ICALL                                         $25     
         60        SEND_VAR                                                 $25
         61        DO_ICALL                                                 
         62      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.45 ms | 1400 KiB | 25 Q