3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Set internal encoding to ISO-8859-9 and assign string an initial value of Turkish characters $t = mb_internal_encoding('ISO-8859-9'); echo "Internal Encoding set? ".$t."\n"; $s = 'ııİöÖğĞçÇşŞ'; $t = mb_internal_encoding(); echo "Internal Encoding: ".$t."\n"; // Check if the string is valid UTF-8 $t = mb_check_encoding($s, 'UTF-8'); echo "Valid UTF-8? ".$t."\n"; // Check if the string is valid ISO-8859-1 $t = mb_check_encoding($s, 'ISO-8859-9'); echo "Valid ISO-8859-9? ".$t."\n"; //Convert string from ISO-8859-9 to ISO-8859-9 while internal encoding is ISO-8859-9 $e = mb_convert_encoding($s, 'ISO-8859-9', 'ISO-8859-9'); echo "Convert string to ISO-8859-9 from ISO-8859-9 while internal encoding ISO-8859-9: ".$e."\n"; //Convert string from ISO-8859-9 to ISO-8859-9 while internal encoding is ISO-8859-9 $i = mb_convert_encoding($s, 'ISO-8859-9'); echo "Convert string to ISO-8859-9 with no source supplied: ".$e."\n"; //Convert string to UTF-8 - if using the detected encoding it will fail $e = mb_convert_encoding($i, 'UTF-8', 'ISO-8859-9'); echo "*** Convert string to UTF-8 from ISO-8859-9: ".$e."\n"; //Display the encoding options available for detection $t = mb_detect_order(); echo "Detect Order: ".print_r($t)."\n"; //Detect encoding of string without influencing the encoding options $t = mb_detect_encoding($s); echo "Encoding detected? ".$t."\n"; //Set a preferred order of matching for detection $t = mb_detect_order('ASCII,UTF-8,ISO-8859-9,ISO-8859-15'); echo "Detect Order set? ".$t."\n"; //Display the encoding options available for detection $t = mb_detect_order(); echo "Detect Order: ".print_r($t)."\n"; //Detect encoding of string after setting the preferred order of detection $t = mb_detect_encoding($s); echo "Encoding detected? ".$t."\n"; //Set internal encoding to UTF-8 $t = mb_internal_encoding('UTF-8'); echo "Internal Encoding set? ".$t."\n"; //Convert string from ISO-8859-9 to ISO-8859-9 while internal encoding is UTF-8 $e = mb_convert_encoding($s, 'ISO-8859-9', 'ISO-8859-9'); echo "Convert string ISO-8859-9 from ISO-8859-9 while internal encoding is UTF-8: ".$e."\n"; //Detect encoding of string $t = mb_detect_encoding($s); echo "Encoding detected? ".$t."\n"; //Convert string to UTF-8 - if using the detected encoding it will fail $e = mb_convert_encoding($s, 'UTF-8', $t); echo "*** Convert string to UTF-8 using Detected Encoding $t as source encoding: ".$e."\n"; //Convert string to UTF-8 - using no source encoding works $e = mb_convert_encoding($s, 'UTF-8'); echo "*** Convert string to UTF-8 without supplying a source encoding: ".$e."\n"; //Convert string to UTF-8 - if using UTF-8 as source $e = mb_convert_encoding($s, 'UTF-8', 'UTF-8'); echo "*** Convert string to UTF-8 using UTF-8 as source encoding: ".$e."\n"; //Even though string is initialised and detected as ISO-8859-9 - it seems it is being treated //internally as though it is actually UTF-8. //Converting to ISO-8859-9 from UTF-8 works - with some characters undisplayable $e = mb_convert_encoding($s, 'ISO-8859-9', 'UTF-8'); echo "Convert string to ISO-8859-9 from UTF-8: ".$e."\n"; //Converting to this string back to UTF-8 from ISO-8859-9 works $e = mb_convert_encoding($e, 'UTF-8', 'ISO-8859-9'); echo "Convert resultant string to UTF-8 from ISO-8859-9: ".$e."\n"; //Converting to this string back to UTF-8 from UTF-8 works $e = mb_convert_encoding($e, 'UTF-8', 'UTF-8'); echo "Convert resultant string to UTF-8 from UTF-8: ".$e."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ihs2Q
function name:  (null)
number of ops:  175
compiled vars:  !0 = $t, !1 = $s, !2 = $e, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'mb_internal_encoding'
          1        SEND_VAL                                                 'ISO-8859-9'
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
    5     4        CONCAT                                           ~6      'Internal+Encoding+set%3F+', !0
          5        CONCAT                                           ~7      ~6, '%0A'
          6        ECHO                                                     ~7
    7     7        ASSIGN                                                   !1, '%C4%B1%C4%B1%C4%B0%C3%B6%C3%96%C4%9F%C4%9E%C3%A7%C3%87%C5%9F%C5%9E'
    9     8        INIT_FCALL                                               'mb_internal_encoding'
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !0, $9
   10    11        CONCAT                                           ~11     'Internal+Encoding%3A+', !0
         12        CONCAT                                           ~12     ~11, '%0A'
         13        ECHO                                                     ~12
   13    14        INIT_FCALL                                               'mb_check_encoding'
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 'UTF-8'
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !0, $13
   14    19        CONCAT                                           ~15     'Valid+UTF-8%3F+', !0
         20        CONCAT                                           ~16     ~15, '%0A'
         21        ECHO                                                     ~16
   17    22        INIT_FCALL                                               'mb_check_encoding'
         23        SEND_VAR                                                 !1
         24        SEND_VAL                                                 'ISO-8859-9'
         25        DO_ICALL                                         $17     
         26        ASSIGN                                                   !0, $17
   18    27        CONCAT                                           ~19     'Valid+ISO-8859-9%3F+', !0
         28        CONCAT                                           ~20     ~19, '%0A'
         29        ECHO                                                     ~20
   21    30        INIT_FCALL                                               'mb_convert_encoding'
         31        SEND_VAR                                                 !1
         32        SEND_VAL                                                 'ISO-8859-9'
         33        SEND_VAL                                                 'ISO-8859-9'
         34        DO_ICALL                                         $21     
         35        ASSIGN                                                   !2, $21
   22    36        CONCAT                                           ~23     'Convert+string+to+ISO-8859-9+from+ISO-8859-9+while+internal+encoding+ISO-8859-9%3A+', !2
         37        CONCAT                                           ~24     ~23, '%0A'
         38        ECHO                                                     ~24
   25    39        INIT_FCALL                                               'mb_convert_encoding'
         40        SEND_VAR                                                 !1
         41        SEND_VAL                                                 'ISO-8859-9'
         42        DO_ICALL                                         $25     
         43        ASSIGN                                                   !3, $25
   26    44        CONCAT                                           ~27     'Convert+string+to+ISO-8859-9+with+no+source+supplied%3A+', !2
         45        CONCAT                                           ~28     ~27, '%0A'
         46        ECHO                                                     ~28
   29    47        INIT_FCALL                                               'mb_convert_encoding'
         48        SEND_VAR                                                 !3
         49        SEND_VAL                                                 'UTF-8'
         50        SEND_VAL                                                 'ISO-8859-9'
         51        DO_ICALL                                         $29     
         52        ASSIGN                                                   !2, $29
   30    53        CONCAT                                           ~31     '%2A%2A%2A+Convert+string+to+UTF-8+from+ISO-8859-9%3A+', !2
         54        CONCAT                                           ~32     ~31, '%0A'
         55        ECHO                                                     ~32
   33    56        INIT_FCALL                                               'mb_detect_order'
         57        DO_ICALL                                         $33     
         58        ASSIGN                                                   !0, $33
   34    59        INIT_FCALL                                               'print_r'
         60        SEND_VAR                                                 !0
         61        DO_ICALL                                         $35     
         62        CONCAT                                           ~36     'Detect+Order%3A+', $35
         63        CONCAT                                           ~37     ~36, '%0A'
         64        ECHO                                                     ~37
   37    65        INIT_FCALL                                               'mb_detect_encoding'
         66        SEND_VAR                                                 !1
         67        DO_ICALL                                         $38     
         68        ASSIGN                                                   !0, $38
   38    69        CONCAT                                           ~40     'Encoding+detected%3F+', !0
         70        CONCAT                                           ~41     ~40, '%0A'
         71        ECHO                                                     ~41
   41    72        INIT_FCALL                                               'mb_detect_order'
         73        SEND_VAL                                                 'ASCII%2CUTF-8%2CISO-8859-9%2CISO-8859-15'
         74        DO_ICALL                                         $42     
         75        ASSIGN                                                   !0, $42
   42    76        CONCAT                                           ~44     'Detect+Order+set%3F+', !0
         77        CONCAT                                           ~45     ~44, '%0A'
         78        ECHO                                                     ~45
   45    79        INIT_FCALL                                               'mb_detect_order'
         80        DO_ICALL                                         $46     
         81        ASSIGN                                                   !0, $46
   46    82        INIT_FCALL                                               'print_r'
         83        SEND_VAR                                                 !0
         84        DO_ICALL                                         $48     
         85        CONCAT                                           ~49     'Detect+Order%3A+', $48
         86        CONCAT                                           ~50     ~49, '%0A'
         87        ECHO                                                     ~50
   49    88        INIT_FCALL                                               'mb_detect_encoding'
         89        SEND_VAR                                                 !1
         90        DO_ICALL                                         $51     
         91        ASSIGN                                                   !0, $51
   50    92        CONCAT                                           ~53     'Encoding+detected%3F+', !0
         93        CONCAT                                           ~54     ~53, '%0A'
         94        ECHO                                                     ~54
   53    95        INIT_FCALL                                               'mb_internal_encoding'
         96        SEND_VAL                                                 'UTF-8'
         97        DO_ICALL                                         $55     
         98        ASSIGN                                                   !0, $55
   54    99        CONCAT                                           ~57     'Internal+Encoding+set%3F+', !0
        100        CONCAT                                           ~58     ~57, '%0A'
        101        ECHO                                                     ~58
   57   102        INIT_FCALL                                               'mb_convert_encoding'
        103        SEND_VAR                                                 !1
        104        SEND_VAL                                                 'ISO-8859-9'
        105        SEND_VAL                                                 'ISO-8859-9'
        106        DO_ICALL                                         $59     
        107        ASSIGN                                                   !2, $59
   58   108        CONCAT                                           ~61     'Convert+string+ISO-8859-9+from+ISO-8859-9+while+internal+encoding+is+UTF-8%3A+', !2
        109        CONCAT                                           ~62     ~61, '%0A'
        110        ECHO                                                     ~62
   61   111        INIT_FCALL                                               'mb_detect_encoding'
        112        SEND_VAR                                                 !1
        113        DO_ICALL                                         $63     
        114        ASSIGN                                                   !0, $63
   62   115        CONCAT                                           ~65     'Encoding+detected%3F+', !0
        116        CONCAT                                           ~66     ~65, '%0A'
        117        ECHO                                                     ~66
   65   118        INIT_FCALL                                               'mb_convert_encoding'
        119        SEND_VAR                                                 !1
        120        SEND_VAL                                                 'UTF-8'
        121        SEND_VAR                                                 !0
        122        DO_ICALL                                         $67     
        123        ASSIGN                                                   !2, $67
   66   124        ROPE_INIT                                     3  ~70     '%2A%2A%2A+Convert+string+to+UTF-8+using+Detected+Encoding+'
        125        ROPE_ADD                                      1  ~70     ~70, !0
        126        ROPE_END                                      2  ~69     ~70, '+as+source+encoding%3A+'
        127        CONCAT                                           ~72     ~69, !2
        128        CONCAT                                           ~73     ~72, '%0A'
        129        ECHO                                                     ~73
   69   130        INIT_FCALL                                               'mb_convert_encoding'
        131        SEND_VAR                                                 !1
        132        SEND_VAL                                                 'UTF-8'
        133        DO_ICALL                                         $74     
        134        ASSIGN                                                   !2, $74
   70   135        CONCAT                                           ~76     '%2A%2A%2A+Convert+string+to+UTF-8+without+supplying+a+source+encoding%3A+', !2
        136        CONCAT                                           ~77     ~76, '%0A'
        137        ECHO                                                     ~77
   73   138        INIT_FCALL                                               'mb_convert_encoding'
        139        SEND_VAR                                                 !1
        140        SEND_VAL                                                 'UTF-8'
        141        SEND_VAL                                                 'UTF-8'
        142        DO_ICALL                                         $78     
        143        ASSIGN                                                   !2, $78
   74   144        CONCAT                                           ~80     '%2A%2A%2A+Convert+string+to+UTF-8+using+UTF-8+as+source+encoding%3A+', !2
        145        CONCAT                                           ~81     ~80, '%0A'
        146        ECHO                                                     ~81
   79   147        INIT_FCALL                                               'mb_convert_encoding'
        148        SEND_VAR                                                 !1
        149        SEND_VAL                                                 'ISO-8859-9'
        150        SEND_VAL                                                 'UTF-8'
        151        DO_ICALL                                         $82     
        152        ASSIGN                                                   !2, $82
   80   153        CONCAT                                           ~84     'Convert+string+to+ISO-8859-9+from+UTF-8%3A+', !2
        154        CONCAT                                           ~85     ~84, '%0A'
        155        ECHO                                                     ~85
   83   156        INIT_FCALL                                               'mb_convert_encoding'
        157        SEND_VAR                                                 !2
        158        SEND_VAL                                                 'UTF-8'
        159        SEND_VAL                                                 'ISO-8859-9'
        160        DO_ICALL                                         $86     
        161        ASSIGN                                                   !2, $86
   84   162        CONCAT                                           ~88     'Convert+resultant+string+to+UTF-8+from+ISO-8859-9%3A+', !2
        163        CONCAT                                           ~89     ~88, '%0A'
        164        ECHO                                                     ~89
   87   165        INIT_FCALL                                               'mb_convert_encoding'
        166        SEND_VAR                                                 !2
        167        SEND_VAL                                                 'UTF-8'
        168        SEND_VAL                                                 'UTF-8'
        169        DO_ICALL                                         $90     
        170        ASSIGN                                                   !2, $90
   88   171        CONCAT                                           ~92     'Convert+resultant+string+to+UTF-8+from+UTF-8%3A+', !2
        172        CONCAT                                           ~93     ~92, '%0A'
        173        ECHO                                                     ~93
        174      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.02 ms | 1023 KiB | 19 Q