3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pcre_stristr($raw,$str,$pos=false){ $r = ''; if($raw!='' && $str!=''){ $str = (string) $str; $tmp = preg_split('/'.preg_quote($str,'/').'/isu',$raw,2,PREG_SPLIT_OFFSET_CAPTURE); if(count($tmp)==2){ if($pos){ $r = $tmp[0][0]; } else{ if($tmp[0][0]==''){ $r = $raw; } else{ $r = substr($raw,strlen($tmp[0][0])); } } } else{ $r = false; } } return $r; } $raw = '0123456789abcdefghijklmnopqrstuvwxyzÁáÀàÂâÄäÃãĄąÆæÇçÉéÈèÊêËëĘęÍíÎîÌìÏïĮįÑñÓóÒòÔôÖöÕõŒœŞşẞßÚúÙùÛûÜüŲųŸÿ0123456789abcdefghijklmnopqrstuvwxyzÁáÀàÂâÄäÃãĄąÆæÇçÉéÈèÊêËëĘęÍíÎîÌìÏïĮįÑñÓóÒòÔôÖöÕõŒœŞşẞßÚúÙùÛûÜüŲųŸÿ'; $len = mb_strlen($raw); $tmp = array(); for($i=0;$i<10000;$i++){ $start = $lenth = 0; $start = mt_rand(0,$len-1); $length = mt_rand(1,min($len-$start,10)); if($start+$length<=$len){ $tmp[] = mb_substr($raw,$start,$length); } } $tmp = array_slice(array_unique($tmp),0,1000); echo '-----compatibility test-----'.PHP_EOL; echo 'samples count: '.count($tmp).PHP_EOL; foreach($tmp as $str){ $chk = true; if($chk && mb_stristr($raw,$str)!=pcre_stristr($raw,$str)){ $chk = false; } if($chk && mb_stristr($raw,$str,true)!=pcre_stristr($raw,$str,true)){ $chk = false; } if(!$chk && $str!='ß'){ echo 'raw: '.$raw.PHP_EOL; echo 'str: '.$str.PHP_EOL.PHP_EOL; echo 'mb_stristr($raw,$str,false)'.PHP_EOL.mb_stristr($raw,$str,false).PHP_EOL.PHP_EOL; echo 'pcre_stristr($raw,$str,false)'.PHP_EOL.pcre_stristr($raw,$str,false).PHP_EOL.PHP_EOL; echo 'mb_stristr($raw,$str,true)'.PHP_EOL.mb_stristr($raw,$str,true).PHP_EOL.PHP_EOL; echo 'pcre_stristr($raw,$str,true)'.PHP_EOL.pcre_stristr($raw,$str,true).PHP_EOL.PHP_EOL; echo 'test failed'; exit(); } } echo 'test finished'.PHP_EOL.PHP_EOL; echo '-----runtime test-----'.PHP_EOL; echo 'mb_stristr() x1000'.PHP_EOL; $time = microtime(true); foreach($tmp as $str){ mb_stristr($raw,$str); } $timea = microtime(true)-$time; echo 'load in '.number_format($timea,5).'ms'.PHP_EOL.PHP_EOL; echo 'pcre_stristr() x1000'.PHP_EOL; $time = microtime(true); foreach($tmp as $str){ pcre_stristr($raw,$str); } $timeb = microtime(true)-$time; echo 'load in '.number_format($timeb,5).'ms'.PHP_EOL.PHP_EOL; echo 'time save '.number_format(100-100*($timeb/$timea),2).'%'; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 8
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 135
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 135
Branch analysis from position: 55
2 jumps found. (Code = 46) Position 1 = 57, Position 2 = 67
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 69
Branch analysis from position: 68
2 jumps found. (Code = 46) Position 1 = 70, Position 2 = 82
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 84
Branch analysis from position: 83
2 jumps found. (Code = 46) Position 1 = 86, Position 2 = 88
Branch analysis from position: 86
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 134
Branch analysis from position: 89
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 134
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 88
Branch analysis from position: 84
Branch analysis from position: 82
Branch analysis from position: 69
Branch analysis from position: 67
Branch analysis from position: 135
2 jumps found. (Code = 77) Position 1 = 144, Position 2 = 150
Branch analysis from position: 144
2 jumps found. (Code = 78) Position 1 = 145, Position 2 = 150
Branch analysis from position: 145
1 jumps found. (Code = 42) Position 1 = 144
Branch analysis from position: 144
Branch analysis from position: 150
2 jumps found. (Code = 77) Position 1 = 171, Position 2 = 177
Branch analysis from position: 171
2 jumps found. (Code = 78) Position 1 = 172, Position 2 = 177
Branch analysis from position: 172
1 jumps found. (Code = 42) Position 1 = 171
Branch analysis from position: 171
Branch analysis from position: 177
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 177
Branch analysis from position: 150
Branch analysis from position: 135
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 36
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 8
Branch analysis from position: 39
Branch analysis from position: 8
Branch analysis from position: 36
filename:       /in/d8IAo
function name:  (null)
number of ops:  203
compiled vars:  !0 = $raw, !1 = $len, !2 = $tmp, !3 = $i, !4 = $start, !5 = $lenth, !6 = $length, !7 = $str, !8 = $chk, !9 = $time, !10 = $timea, !11 = $timeb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, '0123456789abcdefghijklmnopqrstuvwxyz%C3%81%C3%A1%C3%80%C3%A0%C3%82%C3%A2%C3%84%C3%A4%C3%83%C3%A3%C4%84%C4%85%C3%86%C3%A6%C3%87%C3%A7%C3%89%C3%A9%C3%88%C3%A8%C3%8A%C3%AA%C3%8B%C3%AB%C4%98%C4%99%C3%8D%C3%AD%C3%8E%C3%AE%C3%8C%C3%AC%C3%8F%C3%AF%C4%AE%C4%AF%C3%91%C3%B1%C3%93%C3%B3%C3%92%C3%B2%C3%94%C3%B4%C3%96%C3%B6%C3%95%C3%B5%C5%92%C5%93%C5%9E%C5%9F%E1%BA%9E%C3%9F%C3%9A%C3%BA%C3%99%C3%B9%C3%9B%C3%BB%C3%9C%C3%BC%C5%B2%C5%B3%C5%B8%C3%BF0123456789abcdefghijklmnopqrstuvwxyz%C3%81%C3%A1%C3%80%C3%A0%C3%82%C3%A2%C3%84%C3%A4%C3%83%C3%A3%C4%84%C4%85%C3%86%C3%A6%C3%87%C3%A7%C3%89%C3%A9%C3%88%C3%A8%C3%8A%C3%AA%C3%8B%C3%AB%C4%98%C4%99%C3%8D%C3%AD%C3%8E%C3%AE%C3%8C%C3%AC%C3%8F%C3%AF%C4%AE%C4%AF%C3%91%C3%B1%C3%93%C3%B3%C3%92%C3%B2%C3%94%C3%B4%C3%96%C3%B6%C3%95%C3%B5%C5%92%C5%93%C5%9E%C5%9F%E1%BA%9E%C3%9F%C3%9A%C3%BA%C3%99%C3%B9%C3%9B%C3%BB%C3%9C%C3%BC%C5%B2%C5%B3%C5%B8%C3%BF'
   27     1        INIT_FCALL                                               'mb_strlen'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $13     
          4        ASSIGN                                                   !1, $13
   28     5        ASSIGN                                                   !2, <array>
   29     6        ASSIGN                                                   !3, 0
          7      > JMP                                                      ->37
   30     8    >   ASSIGN                                           ~17     !5, 0
          9        ASSIGN                                                   !4, ~17
   31    10        INIT_FCALL                                               'mt_rand'
         11        SEND_VAL                                                 0
         12        SUB                                              ~19     !1, 1
         13        SEND_VAL                                                 ~19
         14        DO_ICALL                                         $20     
         15        ASSIGN                                                   !4, $20
   32    16        INIT_FCALL                                               'mt_rand'
         17        SEND_VAL                                                 1
         18        INIT_FCALL                                               'min'
         19        SUB                                              ~22     !1, !4
         20        SEND_VAL                                                 ~22
         21        SEND_VAL                                                 10
         22        DO_ICALL                                         $23     
         23        SEND_VAR                                                 $23
         24        DO_ICALL                                         $24     
         25        ASSIGN                                                   !6, $24
   33    26        ADD                                              ~26     !4, !6
         27        IS_SMALLER_OR_EQUAL                                      ~26, !1
         28      > JMPZ                                                     ~27, ->36
   34    29    >   INIT_FCALL                                               'mb_substr'
         30        SEND_VAR                                                 !0
         31        SEND_VAR                                                 !4
         32        SEND_VAR                                                 !6
         33        DO_ICALL                                         $29     
         34        ASSIGN_DIM                                               !2
         35        OP_DATA                                                  $29
   29    36    >   PRE_INC                                                  !3
         37    >   IS_SMALLER                                               !3, 10000
         38      > JMPNZ                                                    ~31, ->8
   37    39    >   INIT_FCALL                                               'array_slice'
         40        INIT_FCALL                                               'array_unique'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $32     
         43        SEND_VAR                                                 $32
         44        SEND_VAL                                                 0
         45        SEND_VAL                                                 1000
         46        DO_ICALL                                         $33     
         47        ASSIGN                                                   !2, $33
   38    48        ECHO                                                     '-----compatibility+test-----%0A'
   39    49        COUNT                                            ~35     !2
         50        CONCAT                                           ~36     'samples+count%3A+', ~35
         51        CONCAT                                           ~37     ~36, '%0A'
         52        ECHO                                                     ~37
   40    53      > FE_RESET_R                                       $38     !2, ->135
         54    > > FE_FETCH_R                                               $38, !7, ->135
   41    55    >   ASSIGN                                                   !8, <true>
   42    56      > JMPZ_EX                                          ~40     !8, ->67
         57    >   INIT_FCALL                                               'mb_stristr'
         58        SEND_VAR                                                 !0
         59        SEND_VAR                                                 !7
         60        DO_ICALL                                         $41     
         61        INIT_FCALL                                               'pcre_stristr'
         62        SEND_VAR                                                 !0
         63        SEND_VAR                                                 !7
         64        DO_FCALL                                      0  $42     
         65        IS_NOT_EQUAL                                     ~43     $41, $42
         66        BOOL                                             ~40     ~43
         67    > > JMPZ                                                     ~40, ->69
   43    68    >   ASSIGN                                                   !8, <false>
   45    69    > > JMPZ_EX                                          ~45     !8, ->82
         70    >   INIT_FCALL                                               'mb_stristr'
         71        SEND_VAR                                                 !0
         72        SEND_VAR                                                 !7
         73        SEND_VAL                                                 <true>
         74        DO_ICALL                                         $46     
         75        INIT_FCALL                                               'pcre_stristr'
         76        SEND_VAR                                                 !0
         77        SEND_VAR                                                 !7
         78        SEND_VAL                                                 <true>
         79        DO_FCALL                                      0  $47     
         80        IS_NOT_EQUAL                                     ~48     $46, $47
         81        BOOL                                             ~45     ~48
         82    > > JMPZ                                                     ~45, ->84
   46    83    >   ASSIGN                                                   !8, <false>
   48    84    >   BOOL_NOT                                         ~50     !8
         85      > JMPZ_EX                                          ~50     ~50, ->88
         86    >   IS_NOT_EQUAL                                     ~51     !7, '%C3%9F'
         87        BOOL                                             ~50     ~51
         88    > > JMPZ                                                     ~50, ->134
   49    89    >   CONCAT                                           ~52     'raw%3A+', !0
         90        CONCAT                                           ~53     ~52, '%0A'
         91        ECHO                                                     ~53
   50    92        CONCAT                                           ~54     'str%3A+', !7
         93        CONCAT                                           ~55     ~54, '%0A'
         94        CONCAT                                           ~56     ~55, '%0A'
         95        ECHO                                                     ~56
   51    96        INIT_FCALL                                               'mb_stristr'
         97        SEND_VAR                                                 !0
         98        SEND_VAR                                                 !7
         99        SEND_VAL                                                 <false>
        100        DO_ICALL                                         $57     
        101        CONCAT                                           ~58     'mb_stristr%28%24raw%2C%24str%2Cfalse%29%0A', $57
        102        CONCAT                                           ~59     ~58, '%0A'
        103        CONCAT                                           ~60     ~59, '%0A'
        104        ECHO                                                     ~60
   52   105        INIT_FCALL                                               'pcre_stristr'
        106        SEND_VAR                                                 !0
        107        SEND_VAR                                                 !7
        108        SEND_VAL                                                 <false>
        109        DO_FCALL                                      0  $61     
        110        CONCAT                                           ~62     'pcre_stristr%28%24raw%2C%24str%2Cfalse%29%0A', $61
        111        CONCAT                                           ~63     ~62, '%0A'
        112        CONCAT                                           ~64     ~63, '%0A'
        113        ECHO                                                     ~64
   53   114        INIT_FCALL                                               'mb_stristr'
        115        SEND_VAR                                                 !0
        116        SEND_VAR                                                 !7
        117        SEND_VAL                                                 <true>
        118        DO_ICALL                                         $65     
        119        CONCAT                                           ~66     'mb_stristr%28%24raw%2C%24str%2Ctrue%29%0A', $65
        120        CONCAT                                           ~67     ~66, '%0A'
        121        CONCAT                                           ~68     ~67, '%0A'
        122        ECHO                                                     ~68
   54   123        INIT_FCALL                                               'pcre_stristr'
        124        SEND_VAR                                                 !0
        125        SEND_VAR                                                 !7
        126        SEND_VAL                                                 <true>
        127        DO_FCALL                                      0  $69     
        128        CONCAT                                           ~70     'pcre_stristr%28%24raw%2C%24str%2Ctrue%29%0A', $69
        129        CONCAT                                           ~71     ~70, '%0A'
        130        CONCAT                                           ~72     ~71, '%0A'
        131        ECHO                                                     ~72
   55   132        ECHO                                                     'test+failed'
   56   133      > EXIT                                                     
   40   134    > > JMP                                                      ->54
        135    >   FE_FREE                                                  $38
   59   136        ECHO                                                     'test+finished%0A%0A'
   60   137        ECHO                                                     '-----runtime+test-----%0A'
   61   138        ECHO                                                     'mb_stristr%28%29+x1000%0A'
   62   139        INIT_FCALL                                               'microtime'
        140        SEND_VAL                                                 <true>
        141        DO_ICALL                                         $73     
        142        ASSIGN                                                   !9, $73
   63   143      > FE_RESET_R                                       $75     !2, ->150
        144    > > FE_FETCH_R                                               $75, !7, ->150
   64   145    >   INIT_FCALL                                               'mb_stristr'
        146        SEND_VAR                                                 !0
        147        SEND_VAR                                                 !7
        148        DO_ICALL                                                 
   63   149      > JMP                                                      ->144
        150    >   FE_FREE                                                  $75
   66   151        INIT_FCALL                                               'microtime'
        152        SEND_VAL                                                 <true>
        153        DO_ICALL                                         $77     
        154        SUB                                              ~78     $77, !9
        155        ASSIGN                                                   !10, ~78
   67   156        INIT_FCALL                                               'number_format'
        157        SEND_VAR                                                 !10
        158        SEND_VAL                                                 5
        159        DO_ICALL                                         $80     
        160        CONCAT                                           ~81     'load+in+', $80
        161        CONCAT                                           ~82     ~81, 'ms'
        162        CONCAT                                           ~83     ~82, '%0A'
        163        CONCAT                                           ~84     ~83, '%0A'
        164        ECHO                                                     ~84
   68   165        ECHO                                                     'pcre_stristr%28%29+x1000%0A'
   69   166        INIT_FCALL                                               'microtime'
        167        SEND_VAL                                                 <true>
        168        DO_ICALL                                         $85     
        169        ASSIGN                                                   !9, $85
   70   170      > FE_RESET_R                                       $87     !2, ->177
        171    > > FE_FETCH_R                                               $87, !7, ->177
   71   172    >   INIT_FCALL                                               'pcre_stristr'
        173        SEND_VAR                                                 !0
        174        SEND_VAR                                                 !7
        175        DO_FCALL                                      0          
   70   176      > JMP                                                      ->171
        177    >   FE_FREE                                                  $87
   73   178        INIT_FCALL                                               'microtime'
        179        SEND_VAL                                                 <true>
        180        DO_ICALL                                         $89     
        181        SUB                                              ~90     $89, !9
        182        ASSIGN                                                   !11, ~90
   74   183        INIT_FCALL                                               'number_format'
        184        SEND_VAR                                                 !11
        185        SEND_VAL                                                 5
        186        DO_ICALL                                         $92     
        187        CONCAT                                           ~93     'load+in+', $92
        188        CONCAT                                           ~94     ~93, 'ms'
        189        CONCAT                                           ~95     ~94, '%0A'
        190        CONCAT                                           ~96     ~95, '%0A'
        191        ECHO                                                     ~96
   75   192        INIT_FCALL                                               'number_format'
        193        DIV                                              ~97     !11, !10
        194        MUL                                              ~98     ~97, 100
        195        SUB                                              ~99     100, ~98
        196        SEND_VAL                                                 ~99
        197        SEND_VAL                                                 2
        198        DO_ICALL                                         $100    
        199        CONCAT                                           ~101    'time+save+', $100
        200        CONCAT                                           ~102    ~101, '%25'
        201        ECHO                                                     ~102
   76   202      > RETURN                                                   1

Function pcre_stristr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 48
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 47
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 8
filename:       /in/d8IAo
function name:  pcre_stristr
number of ops:  50
compiled vars:  !0 = $raw, !1 = $str, !2 = $pos, !3 = $r, !4 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
    3     3        ASSIGN                                                   !3, ''
    4     4        IS_NOT_EQUAL                                     ~6      !0, ''
          5      > JMPZ_EX                                          ~6      ~6, ->8
          6    >   IS_NOT_EQUAL                                     ~7      !1, ''
          7        BOOL                                             ~6      ~7
          8    > > JMPZ                                                     ~6, ->48
    5     9    >   CAST                                          6  ~8      !1
         10        ASSIGN                                                   !1, ~8
    6    11        INIT_FCALL                                               'preg_split'
         12        INIT_FCALL                                               'preg_quote'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 '%2F'
         15        DO_ICALL                                         $10     
         16        CONCAT                                           ~11     '%2F', $10
         17        CONCAT                                           ~12     ~11, '%2Fisu'
         18        SEND_VAL                                                 ~12
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 2
         21        SEND_VAL                                                 4
         22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !4, $13
    7    24        COUNT                                            ~15     !4
         25        IS_EQUAL                                                 ~15, 2
         26      > JMPZ                                                     ~16, ->47
    8    27    > > JMPZ                                                     !2, ->32
    9    28    >   FETCH_DIM_R                                      ~17     !4, 0
         29        FETCH_DIM_R                                      ~18     ~17, 0
         30        ASSIGN                                                   !3, ~18
         31      > JMP                                                      ->46
   12    32    >   FETCH_DIM_R                                      ~20     !4, 0
         33        FETCH_DIM_R                                      ~21     ~20, 0
         34        IS_EQUAL                                                 ~21, ''
         35      > JMPZ                                                     ~22, ->38
   13    36    >   ASSIGN                                                   !3, !0
         37      > JMP                                                      ->46
   16    38    >   INIT_FCALL                                               'substr'
         39        SEND_VAR                                                 !0
         40        FETCH_DIM_R                                      ~24     !4, 0
         41        FETCH_DIM_R                                      ~25     ~24, 0
         42        STRLEN                                           ~26     ~25
         43        SEND_VAL                                                 ~26
         44        DO_ICALL                                         $27     
         45        ASSIGN                                                   !3, $27
         46    > > JMP                                                      ->48
   21    47    >   ASSIGN                                                   !3, <false>
   24    48    > > RETURN                                                   !3
   25    49*     > RETURN                                                   null

End of function pcre_stristr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.9 ms | 1414 KiB | 42 Q