3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = array( 'ASCII' => 'ASCII', 'UTF-8' => "Tr\xc3\xb6t", 'Windows-1252 with ASCII' => "Tr\xf6t", 'Windows-1252 only' => "\xf6\xfd\x80", 'Windows-1252 only with an undefined character' => "\xf6\xfd\x81", ); $detect = array('ASCII', 'Windows-1252', 'UTF-8'); foreach ($strings as $name => $string) { $detected_loose = mb_detect_encoding($string, $detect, true); $detected_strict = mb_detect_encoding($string, $detect, false); if ($detected_loose === $detected_strict) { if ($detected_loose === false) { echo "'$name' could not be detected!\n"; } else { echo "'$name' was detected as $detected_loose\n"; } } else { echo "'$name' was " . ($detected_loose === false ? 'not detected' : "detected as $detected_loose") . ' in loose mode, but ' . ($detected_strict === false ? 'not detected' : "detected as $detected_strict") . " in strict mode\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 56
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 56
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 33
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
Branch analysis from position: 49
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/8GaP0
function name:  (null)
number of ops:  58
compiled vars:  !0 = $strings, !1 = $detect, !2 = $string, !3 = $name, !4 = $detected_loose, !5 = $detected_strict
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   13     2      > FE_RESET_R                                       $8      !0, ->56
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->56
          4    >   ASSIGN                                                   !3, ~9
   14     5        INIT_FCALL                                               'mb_detect_encoding'
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $11     
         10        ASSIGN                                                   !4, $11
   15    11        INIT_FCALL                                               'mb_detect_encoding'
         12        SEND_VAR                                                 !2
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 <false>
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !5, $13
   16    17        IS_IDENTICAL                                             !4, !5
         18      > JMPZ                                                     ~15, ->33
   17    19    >   TYPE_CHECK                                    4          !4
         20      > JMPZ                                                     ~16, ->26
   18    21    >   ROPE_INIT                                     3  ~18     '%27'
         22        ROPE_ADD                                      1  ~18     ~18, !3
         23        ROPE_END                                      2  ~17     ~18, '%27+could+not+be+detected%21%0A'
         24        ECHO                                                     ~17
         25      > JMP                                                      ->32
   20    26    >   ROPE_INIT                                     5  ~21     '%27'
         27        ROPE_ADD                                      1  ~21     ~21, !3
         28        ROPE_ADD                                      2  ~21     ~21, '%27+was+detected+as+'
         29        ROPE_ADD                                      3  ~21     ~21, !4
         30        ROPE_END                                      4  ~20     ~21, '%0A'
         31        ECHO                                                     ~20
         32    > > JMP                                                      ->55
   23    33    >   ROPE_INIT                                     3  ~25     '%27'
         34        ROPE_ADD                                      1  ~25     ~25, !3
         35        ROPE_END                                      2  ~24     ~25, '%27+was+'
   24    36        TYPE_CHECK                                    4          !4
         37      > JMPZ                                                     ~27, ->40
         38    >   QM_ASSIGN                                        ~28     'not+detected'
         39      > JMP                                                      ->43
         40    >   NOP                                                      
         41        FAST_CONCAT                                      ~29     'detected+as+', !4
         42        QM_ASSIGN                                        ~28     ~29
         43    >   CONCAT                                           ~30     ~24, ~28
   25    44        CONCAT                                           ~31     ~30, '+in+loose+mode%2C+but+'
   26    45        TYPE_CHECK                                    4          !5
         46      > JMPZ                                                     ~32, ->49
         47    >   QM_ASSIGN                                        ~33     'not+detected'
         48      > JMP                                                      ->52
         49    >   NOP                                                      
         50        FAST_CONCAT                                      ~34     'detected+as+', !5
         51        QM_ASSIGN                                        ~33     ~34
         52    >   CONCAT                                           ~35     ~31, ~33
   27    53        CONCAT                                           ~36     ~35, '+in+strict+mode%0A'
         54        ECHO                                                     ~36
   13    55    > > JMP                                                      ->3
         56    >   FE_FREE                                                  $8
   29    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.2 ms | 1400 KiB | 15 Q