3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str1 = '14'; $str2 = 'DQ'; //$encodings1 = ['UTF-16LE', 'UTF-16', 'UTF-8', 'ASCII']; $encodings1 = ['UTF-8', 'UTF-16', 'UTF-16LE', 'ASCII']; $encodings2 = ['UTF-16LE', 'UTF-16', 'UTF-8']; function is_multiencodings($list, $string) { $current = '0'; foreach($list as $key => $val) { $old = $current; $current = mb_detect_encoding($string, $val, true); if(!is_string($current)) { if('0' != $old) { $current = '' . $key; } else { $current = '0'; } } if($old && $current != $old) { var_dump($Los, $current); return true; } } } var_dump(is_multiencodings($encodings1, $str1)); echo bin2hex($str1) . ' - ' . mb_detect_encoding($str1, $encodings1, true)."\n"; echo bin2hex($str1) . ' - ' . mb_detect_encoding($str1, $encodings2, true)."\n"; echo bin2hex($str2) . ' - ' . mb_detect_encoding($str2, $encodings1, true)."\n"; echo bin2hex($str2) . ' - ' . mb_detect_encoding($str2, $encodings2, true)."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/79sEZ
function name:  (null)
number of ops:  60
compiled vars:  !0 = $str1, !1 = $str2, !2 = $encodings1, !3 = $encodings2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '14'
    4     1        ASSIGN                                                   !1, 'DQ'
    6     2        ASSIGN                                                   !2, <array>
    7     3        ASSIGN                                                   !3, <array>
   26     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'is_multiencodings'
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR                                                 $8
         10        DO_ICALL                                                 
   27    11        INIT_FCALL                                               'bin2hex'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $10     
         14        CONCAT                                           ~11     $10, '+-+'
         15        INIT_FCALL                                               'mb_detect_encoding'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !2
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $12     
         20        CONCAT                                           ~13     ~11, $12
         21        CONCAT                                           ~14     ~13, '%0A'
         22        ECHO                                                     ~14
   28    23        INIT_FCALL                                               'bin2hex'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $15     
         26        CONCAT                                           ~16     $15, '+-+'
         27        INIT_FCALL                                               'mb_detect_encoding'
         28        SEND_VAR                                                 !0
         29        SEND_VAR                                                 !3
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $17     
         32        CONCAT                                           ~18     ~16, $17
         33        CONCAT                                           ~19     ~18, '%0A'
         34        ECHO                                                     ~19
   29    35        INIT_FCALL                                               'bin2hex'
         36        SEND_VAR                                                 !1
         37        DO_ICALL                                         $20     
         38        CONCAT                                           ~21     $20, '+-+'
         39        INIT_FCALL                                               'mb_detect_encoding'
         40        SEND_VAR                                                 !1
         41        SEND_VAR                                                 !2
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $22     
         44        CONCAT                                           ~23     ~21, $22
         45        CONCAT                                           ~24     ~23, '%0A'
         46        ECHO                                                     ~24
   30    47        INIT_FCALL                                               'bin2hex'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                         $25     
         50        CONCAT                                           ~26     $25, '+-+'
         51        INIT_FCALL                                               'mb_detect_encoding'
         52        SEND_VAR                                                 !1
         53        SEND_VAR                                                 !3
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $27     
         56        CONCAT                                           ~28     ~26, $27
         57        CONCAT                                           ~29     ~28, '%0A'
         58        ECHO                                                     ~29
         59      > RETURN                                                   1

Function is_multiencodings:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 33
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 33
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 25
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
Branch analysis from position: 25
Branch analysis from position: 22
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/79sEZ
function name:  is_multiencodings
number of ops:  35
compiled vars:  !0 = $list, !1 = $string, !2 = $current, !3 = $val, !4 = $key, !5 = $old, !6 = $Los
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN                                                   !2, '0'
   10     3      > FE_RESET_R                                       $8      !0, ->33
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->33
          5    >   ASSIGN                                                   !4, ~9
   11     6        ASSIGN                                                   !5, !2
   12     7        INIT_FCALL                                               'mb_detect_encoding'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !3
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !2, $12
   13    13        TYPE_CHECK                                   64  ~14     !2
         14        BOOL_NOT                                         ~15     ~14
         15      > JMPZ                                                     ~15, ->22
   14    16    >   IS_NOT_EQUAL                                             !5, '0'
         17      > JMPZ                                                     ~16, ->21
   15    18    >   CONCAT                                           ~17     '', !4
         19        ASSIGN                                                   !2, ~17
         20      > JMP                                                      ->22
   17    21    >   ASSIGN                                                   !2, '0'
   20    22    > > JMPZ_EX                                          ~20     !5, ->25
         23    >   IS_NOT_EQUAL                                     ~21     !2, !5
         24        BOOL                                             ~20     ~21
         25    > > JMPZ                                                     ~20, ->32
   21    26    >   INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !6
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
   22    30        FE_FREE                                                  $8
         31      > RETURN                                                   <true>
   10    32    > > JMP                                                      ->4
         33    >   FE_FREE                                                  $8
   25    34      > RETURN                                                   null

End of function is_multiencodings

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.9 ms | 1407 KiB | 20 Q