3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_errors', '1'); // display runtime errors error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); // error reporting date_default_timezone_set('UTC'); function detect_encoding($ystr, $csetlist='UTF-8, ISO-8859-1, ISO-8859-15, ISO-8859-2, ISO-8859-9, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-10, ISO-8859-13, ISO-8859-14, ISO-8859-16, UTF-7, ASCII, SJIS, EUC-JP, JIS, ISO-2022-JP, EUC-CN, GB18030, ISO-2022-KR, KOI8-R, KOI8-U') { // Fix: starting from PHP 7.1 it warns about illegal argument if using: ISO-8859-11 return mb_detect_encoding((string)$ystr, (string)$csetlist, true); // mixed: (bool) FALSE or (string) 'CHARSET' } $str = 'A + B'; echo detect_encoding($str); echo "\n"; echo mb_convert_encoding($str, 'UTF-8', detect_encoding($str)); echo "\n"; echo "\n"; $str = 'A - B'; echo detect_encoding('A - B'); echo "\n"; echo mb_convert_encoding($str, 'UTF-8', detect_encoding($str));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ib2Fd
function name:  (null)
number of ops:  43
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'display_errors'
          2        SEND_VAL                                                 '1'
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'error_reporting'
          5        SEND_VAL                                                 22519
          6        DO_ICALL                                                 
    5     7        INIT_FCALL                                               'date_default_timezone_set'
          8        SEND_VAL                                                 'UTC'
          9        DO_ICALL                                                 
   11    10        ASSIGN                                                   !0, 'A+%2B+B'
   12    11        INIT_FCALL                                               'detect_encoding'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $5      
         14        ECHO                                                     $5
   13    15        ECHO                                                     '%0A'
   14    16        INIT_FCALL                                               'mb_convert_encoding'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 'UTF-8'
         19        INIT_FCALL                                               'detect_encoding'
         20        SEND_VAR                                                 !0
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                         $7      
         24        ECHO                                                     $7
   15    25        ECHO                                                     '%0A'
   16    26        ECHO                                                     '%0A'
   17    27        ASSIGN                                                   !0, 'A+-+B'
   18    28        INIT_FCALL                                               'detect_encoding'
         29        SEND_VAL                                                 'A+-+B'
         30        DO_FCALL                                      0  $9      
         31        ECHO                                                     $9
   19    32        ECHO                                                     '%0A'
   20    33        INIT_FCALL                                               'mb_convert_encoding'
         34        SEND_VAR                                                 !0
         35        SEND_VAL                                                 'UTF-8'
         36        INIT_FCALL                                               'detect_encoding'
         37        SEND_VAR                                                 !0
         38        DO_FCALL                                      0  $10     
         39        SEND_VAR                                                 $10
         40        DO_ICALL                                         $11     
         41        ECHO                                                     $11
         42      > RETURN                                                   1

Function detect_encoding:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ib2Fd
function name:  detect_encoding
number of ops:  11
compiled vars:  !0 = $ystr, !1 = $csetlist
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'UTF-8%2C+ISO-8859-1%2C+ISO-8859-15%2C+ISO-8859-2%2C+ISO-8859-9%2C+ISO-8859-3%2C+ISO-8859-4%2C+ISO-8859-5%2C+ISO-8859-6%2C+ISO-8859-7%2C+ISO-8859-8%2C+ISO-8859-10%2C+ISO-8859-13%2C+ISO-8859-14%2C+ISO-8859-16%2C+UTF-7%2C+ASCII%2C+SJIS%2C+EUC-JP%2C+JIS%2C+ISO-2022-JP%2C+EUC-CN%2C+GB18030%2C+ISO-2022-KR%2C+KOI8-R%2C+KOI8-U'
    8     2        INIT_FCALL                                               'mb_detect_encoding'
          3        CAST                                          6  ~2      !0
          4        SEND_VAL                                                 ~2
          5        CAST                                          6  ~3      !1
          6        SEND_VAL                                                 ~3
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $4      
          9      > RETURN                                                   $4
    9    10*     > RETURN                                                   null

End of function detect_encoding

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.49 ms | 1009 KiB | 22 Q