3v4l.org

run code in 300+ PHP versions simultaneously
<?php $examples = array( 'Valid ASCII' => "a", 'Valid 2 Octet Sequence' => "\xc3\xb1", 'Invalid 2 Octet Sequence' => "\xc3\x28", 'Invalid Sequence Identifier' => "\xa0\xa1", 'Valid 3 Octet Sequence' => "\xe2\x82\xa1", 'Invalid 3 Octet Sequence (in 2nd Octet)' => "\xe2\x28\xa1", 'Invalid 3 Octet Sequence (in 3rd Octet)' => "\xe2\x82\x28", 'Valid 4 Octet Sequence' => "\xf0\x90\x8c\xbc", 'Invalid 4 Octet Sequence (in 2nd Octet)' => "\xf0\x28\x8c\xbc", 'Invalid 4 Octet Sequence (in 3rd Octet)' => "\xf0\x90\x28\xbc", 'Invalid 4 Octet Sequence (in 4th Octet)' => "\xf0\x28\x8c\x28", 'Valid 5 Octet Sequence (but not Unicode!)' => "\xf8\xa1\xa1\xa1\xa1", 'Valid 6 Octet Sequence (but not Unicode!)' => "\xfc\xa1\xa1\xa1\xa1\xa1", ); echo "++Invalid UTF-8 in pattern\n"; foreach ( $examples as $name => $str ) { echo "$name\n"; preg_match("/".$str."/u",'Testing'); } echo "++ preg_match() examples\n"; foreach ( $examples as $name => $str ) { preg_match("/\xf8\xa1\xa1\xa1\xa1/u", $str, $ar); echo "$name: "; if ( count($ar) == 0 ) { echo "Matched nothing!\n"; } else { echo "Matched {$ar[0]}\n"; } } echo "++ preg_match_all() examples\n"; foreach ( $examples as $name => $str ) { preg_match_all('/./u', $str, $ar); echo "$name: "; $num_utf8_chars = count($ar[0]); if ( $num_utf8_chars == 0 ) { echo "Matched nothing!\n"; } else { echo "Matched $num_utf8_chars character\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 39
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 39
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 64
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 64
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 59
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
Branch analysis from position: 39
Branch analysis from position: 15
filename:       /in/T1vk1
function name:  (null)
number of ops:  66
compiled vars:  !0 = $examples, !1 = $str, !2 = $name, !3 = $ar, !4 = $num_utf8_chars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   19     1        ECHO                                                     '%2B%2BInvalid+UTF-8+in+pattern%0A'
   20     2      > FE_RESET_R                                       $6      !0, ->15
          3    > > FE_FETCH_R                                       ~7      $6, !1, ->15
          4    >   ASSIGN                                                   !2, ~7
   21     5        NOP                                                      
          6        FAST_CONCAT                                      ~9      !2, '%0A'
          7        ECHO                                                     ~9
   22     8        INIT_FCALL                                               'preg_match'
          9        CONCAT                                           ~10     '%2F', !1
         10        CONCAT                                           ~11     ~10, '%2Fu'
         11        SEND_VAL                                                 ~11
         12        SEND_VAL                                                 'Testing'
         13        DO_ICALL                                                 
   20    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $6
   25    16        ECHO                                                     '%2B%2B+preg_match%28%29+examples%0A'
   26    17      > FE_RESET_R                                       $13     !0, ->39
         18    > > FE_FETCH_R                                       ~14     $13, !1, ->39
         19    >   ASSIGN                                                   !2, ~14
   28    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAL                                                 '%2F%F8%A1%A1%A1%A1%2Fu'
         22        SEND_VAR                                                 !1
         23        SEND_REF                                                 !3
         24        DO_ICALL                                                 
   29    25        NOP                                                      
         26        FAST_CONCAT                                      ~17     !2, '%3A+'
         27        ECHO                                                     ~17
   31    28        COUNT                                            ~18     !3
         29        IS_EQUAL                                                 ~18, 0
         30      > JMPZ                                                     ~19, ->33
   32    31    >   ECHO                                                     'Matched+nothing%21%0A'
         32      > JMP                                                      ->38
   34    33    >   ROPE_INIT                                     3  ~22     'Matched+'
         34        FETCH_DIM_R                                      ~20     !3, 0
         35        ROPE_ADD                                      1  ~22     ~22, ~20
         36        ROPE_END                                      2  ~21     ~22, '%0A'
         37        ECHO                                                     ~21
   26    38    > > JMP                                                      ->18
         39    >   FE_FREE                                                  $13
   39    40        ECHO                                                     '%2B%2B+preg_match_all%28%29+examples%0A'
   40    41      > FE_RESET_R                                       $24     !0, ->64
         42    > > FE_FETCH_R                                       ~25     $24, !1, ->64
         43    >   ASSIGN                                                   !2, ~25
   41    44        INIT_FCALL                                               'preg_match_all'
         45        SEND_VAL                                                 '%2F.%2Fu'
         46        SEND_VAR                                                 !1
         47        SEND_REF                                                 !3
         48        DO_ICALL                                                 
   42    49        NOP                                                      
         50        FAST_CONCAT                                      ~28     !2, '%3A+'
         51        ECHO                                                     ~28
   44    52        FETCH_DIM_R                                      ~29     !3, 0
         53        COUNT                                            ~30     ~29
         54        ASSIGN                                                   !4, ~30
   45    55        IS_EQUAL                                                 !4, 0
         56      > JMPZ                                                     ~32, ->59
   46    57    >   ECHO                                                     'Matched+nothing%21%0A'
         58      > JMP                                                      ->63
   48    59    >   ROPE_INIT                                     3  ~34     'Matched+'
         60        ROPE_ADD                                      1  ~34     ~34, !4
         61        ROPE_END                                      2  ~33     ~34, '+character%0A'
         62        ECHO                                                     ~33
   40    63    > > JMP                                                      ->42
         64    >   FE_FREE                                                  $24
   51    65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.04 ms | 1400 KiB | 17 Q