3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo mb_internal_encoding(), "\n\n\n"; /* premier test: on convertit en ISO-8859-1 pour produire des séquences UTF-8 invalides. Bien entendu, comme mb_internal_encoding est UTF-8, c'est dans cette encodage que mb_strlen va tenter de les lire. On remarque l'incohérence des résultats pour PHP < 8.3, résultats qui dépendent de la localisation du caractère  dans la chaîne. */ $test1 = [ 'mAm', 'mÂ', 'mÂm', 'mÂÂm' ]; echo "test 1:\n\n"; foreach ($test1 as $s) { printf( "%s:\n UTF-8: %d ISO-8859-1: %d\n", $s, mb_strlen($s), mb_strlen(mb_convert_encoding($s, 'ISO-8859-1', 'UTF-8')) ); } echo "\n\n\n"; /* ici on teste le caractère U+2030 ‰ e2 80 b0 PER MILLE SIGN, on interrompt sa séquence et on essaie différents cas de figure pour la suite */ $test2 = ["\xe2\x80\xb0", "\xe2\x80", "\xe2\x80L", "\xe2\x80\xe2\x80", "\xe2\x80LL"]; echo "test 2:\n\n"; foreach ($test2 as $s) { printf( "%s: UTF-8: %d\n", $s, mb_strlen($s) ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 41
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 26
filename:       /in/Hd7Y9
function name:  (null)
number of ops:  43
compiled vars:  !0 = $test1, !1 = $s, !2 = $test2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'mb_internal_encoding'
          1        DO_ICALL                                         $3      
          2        ECHO                                                     $3
          3        ECHO                                                     '%0A%0A%0A'
   12     4        ASSIGN                                                   !0, <array>
   14     5        ECHO                                                     'test+1%3A%0A%0A'
   16     6      > FE_RESET_R                                       $5      !0, ->26
          7    > > FE_FETCH_R                                               $5, !1, ->26
   17     8    >   INIT_FCALL                                               'printf'
   18     9        SEND_VAL                                                 '%25s%3A%0A++++UTF-8%3A+%25d++++ISO-8859-1%3A+%25d%0A'
   19    10        SEND_VAR                                                 !1
   20    11        INIT_FCALL                                               'mb_strlen'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
   21    15        INIT_FCALL                                               'mb_strlen'
         16        INIT_FCALL                                               'mb_convert_encoding'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 'ISO-8859-1'
         19        SEND_VAL                                                 'UTF-8'
         20        DO_ICALL                                         $7      
         21        SEND_VAR                                                 $7
         22        DO_ICALL                                         $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                                 
   16    25      > JMP                                                      ->7
         26    >   FE_FREE                                                  $5
   25    27        ECHO                                                     '%0A%0A%0A'
   30    28        ASSIGN                                                   !2, <array>
   32    29        ECHO                                                     'test+2%3A%0A%0A'
   34    30      > FE_RESET_R                                       $11     !2, ->41
         31    > > FE_FETCH_R                                               $11, !1, ->41
   35    32    >   INIT_FCALL                                               'printf'
   36    33        SEND_VAL                                                 '%25s%3A++++UTF-8%3A+%25d%0A'
   37    34        SEND_VAR                                                 !1
   38    35        INIT_FCALL                                               'mb_strlen'
         36        SEND_VAR                                                 !1
         37        DO_ICALL                                         $12     
         38        SEND_VAR                                                 $12
         39        DO_ICALL                                                 
   34    40      > JMP                                                      ->31
         41    >   FE_FREE                                                  $11
   40    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
133.93 ms | 1405 KiB | 21 Q