3v4l.org

run code in 500+ 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 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 8
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 133
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 133
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 54, Position 2 = 64
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 66
Branch analysis from position: 65
2 jumps found. (Code = 46) Position 1 = 67, Position 2 = 79
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 81
Branch analysis from position: 80
2 jumps found. (Code = 46) Position 1 = 83, Position 2 = 85
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 132
Branch analysis from position: 86
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 132
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 85
Branch analysis from position: 81
Branch analysis from position: 79
Branch analysis from position: 66
Branch analysis from position: 64
Branch analysis from position: 133
2 jumps found. (Code = 77) Position 1 = 142, Position 2 = 148
Branch analysis from position: 142
2 jumps found. (Code = 78) Position 1 = 143, Position 2 = 148
Branch analysis from position: 143
1 jumps found. (Code = 42) Position 1 = 142
Branch analysis from position: 142
Branch analysis from position: 148
2 jumps found. (Code = 77) Position 1 = 169, Position 2 = 175
Branch analysis from position: 169
2 jumps found. (Code = 78) Position 1 = 170, Position 2 = 175
Branch analysis from position: 170
1 jumps found. (Code = 42) Position 1 = 169
Branch analysis from position: 169
Branch analysis from position: 175
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 175
Branch analysis from position: 148
Branch analysis from position: 133
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 33
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 8
Branch analysis from position: 36
Branch analysis from position: 8
Branch analysis from position: 33
filename:       /in/d8IAo
function name:  (null)
number of ops:  201
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                                                          ->34
   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        SUB                                                  ~22     !1, !4
         19        FRAMELESS_ICALL_2                min                 ~23     ~22, 10
         20        SEND_VAL                                                     ~23
         21        DO_ICALL                                             $24     
         22        ASSIGN                                                       !6, $24
   33    23        ADD                                                  ~26     !4, !6
         24        IS_SMALLER_OR_EQUAL                                          ~26, !1
         25      > JMPZ                                                         ~27, ->33
   34    26    >   INIT_FCALL                                                   'mb_substr'
         27        SEND_VAR                                                     !0
         28        SEND_VAR                                                     !4
         29        SEND_VAR                                                     !6
         30        DO_ICALL                                             $29     
         31        ASSIGN_DIM                                                   !2
         32        OP_DATA                                                      $29
   29    33    >   PRE_INC                                                      !3
         34    >   IS_SMALLER                                                   !3, 10000
         35      > JMPNZ                                                        ~31, ->8
   37    36    >   INIT_FCALL                                                   'array_slice'
         37        INIT_FCALL                                                   'array_unique'
         38        SEND_VAR                                                     !2
         39        DO_ICALL                                             $32     
         40        SEND_VAR                                                     $32
         41        SEND_VAL                                                     0
         42        SEND_VAL                                                     1000
         43        DO_ICALL                                             $33     
         44        ASSIGN                                                       !2, $33
   38    45        ECHO                                                         '-----compatibility+test-----%0A'
   39    46        COUNT                                                ~35     !2
         47        CONCAT                                               ~36     'samples+count%3A+', ~35
         48        CONCAT                                               ~37     ~36, '%0A'
         49        ECHO                                                         ~37
   40    50      > FE_RESET_R                                           $38     !2, ->133
         51    > > FE_FETCH_R                                                   $38, !7, ->133
   41    52    >   ASSIGN                                                       !8, <true>
   42    53      > JMPZ_EX                                              ~40     !8, ->64
         54    >   INIT_FCALL                                                   'mb_stristr'
         55        SEND_VAR                                                     !0
         56        SEND_VAR                                                     !7
         57        DO_ICALL                                             $41     
         58        INIT_FCALL                                                   'pcre_stristr'
         59        SEND_VAR                                                     !0
         60        SEND_VAR                                                     !7
         61        DO_FCALL                                          0  $42     
         62        IS_NOT_EQUAL                                         ~43     $41, $42
         63        BOOL                                                 ~40     ~43
         64    > > JMPZ                                                         ~40, ->66
   43    65    >   ASSIGN                                                       !8, <false>
   45    66    > > JMPZ_EX                                              ~45     !8, ->79
         67    >   INIT_FCALL                                                   'mb_stristr'
         68        SEND_VAR                                                     !0
         69        SEND_VAR                                                     !7
         70        SEND_VAL                                                     <true>
         71        DO_ICALL                                             $46     
         72        INIT_FCALL                                                   'pcre_stristr'
         73        SEND_VAR                                                     !0
         74        SEND_VAR                                                     !7
         75        SEND_VAL                                                     <true>
         76        DO_FCALL                                          0  $47     
         77        IS_NOT_EQUAL                                         ~48     $46, $47
         78        BOOL                                                 ~45     ~48
         79    > > JMPZ                                                         ~45, ->81
   46    80    >   ASSIGN                                                       !8, <false>
   48    81    >   BOOL_NOT                                             ~50     !8
         82      > JMPZ_EX                                              ~50     ~50, ->85
         83    >   IS_NOT_EQUAL                                         ~51     !7, '%C3%9F'
         84        BOOL                                                 ~50     ~51
         85    > > JMPZ                                                         ~50, ->132
   49    86    >   CONCAT                                               ~52     'raw%3A+', !0
         87        CONCAT                                               ~53     ~52, '%0A'
         88        ECHO                                                         ~53
   50    89        CONCAT                                               ~54     'str%3A+', !7
         90        CONCAT                                               ~55     ~54, '%0A'
         91        CONCAT                                               ~56     ~55, '%0A'
         92        ECHO                                                         ~56
   51    93        INIT_FCALL                                                   'mb_stristr'
         94        SEND_VAR                                                     !0
         95        SEND_VAR                                                     !7
         96        SEND_VAL                                                     <false>
         97        DO_ICALL                                             $57     
         98        CONCAT                                               ~58     'mb_stristr%28%24raw%2C%24str%2Cfalse%29%0A', $57
         99        CONCAT                                               ~59     ~58, '%0A'
        100        CONCAT                                               ~60     ~59, '%0A'
        101        ECHO                                                         ~60
   52   102        INIT_FCALL                                                   'pcre_stristr'
        103        SEND_VAR                                                     !0
        104        SEND_VAR                                                     !7
        105        SEND_VAL                                                     <false>
        106        DO_FCALL                                          0  $61     
        107        CONCAT                                               ~62     'pcre_stristr%28%24raw%2C%24str%2Cfalse%29%0A', $61
        108        CONCAT                                               ~63     ~62, '%0A'
        109        CONCAT                                               ~64     ~63, '%0A'
        110        ECHO                                                         ~64
   53   111        INIT_FCALL                                                   'mb_stristr'
        112        SEND_VAR                                                     !0
        113        SEND_VAR                                                     !7
        114        SEND_VAL                                                     <true>
        115        DO_ICALL                                             $65     
        116        CONCAT                                               ~66     'mb_stristr%28%24raw%2C%24str%2Ctrue%29%0A', $65
        117        CONCAT                                               ~67     ~66, '%0A'
        118        CONCAT                                               ~68     ~67, '%0A'
        119        ECHO                                                         ~68
   54   120        INIT_FCALL                                                   'pcre_stristr'
        121        SEND_VAR                                                     !0
        122        SEND_VAR                                                     !7
        123        SEND_VAL                                                     <true>
        124        DO_FCALL                                          0  $69     
        125        CONCAT                                               ~70     'pcre_stristr%28%24raw%2C%24str%2Ctrue%29%0A', $69
        126        CONCAT                                               ~71     ~70, '%0A'
        127        CONCAT                                               ~72     ~71, '%0A'
        128        ECHO                                                         ~72
   55   129        ECHO                                                         'test+failed'
   56   130      > INIT_FCALL                                                   'exit'
        131*       DO_ICALL                                                     
   40   132    > > JMP                                                          ->51
        133    >   FE_FREE                                                      $38
   59   134        ECHO                                                         'test+finished%0A%0A'
   60   135        ECHO                                                         '-----runtime+test-----%0A'
   61   136        ECHO                                                         'mb_stristr%28%29+x1000%0A'
   62   137        INIT_FCALL                                                   'microtime'
        138        SEND_VAL                                                     <true>
        139        DO_ICALL                                             $74     
        140        ASSIGN                                                       !9, $74
   63   141      > FE_RESET_R                                           $76     !2, ->148
        142    > > FE_FETCH_R                                                   $76, !7, ->148
   64   143    >   INIT_FCALL                                                   'mb_stristr'
        144        SEND_VAR                                                     !0
        145        SEND_VAR                                                     !7
        146        DO_ICALL                                                     
   63   147      > JMP                                                          ->142
        148    >   FE_FREE                                                      $76
   66   149        INIT_FCALL                                                   'microtime'
        150        SEND_VAL                                                     <true>
        151        DO_ICALL                                             $78     
        152        SUB                                                  ~79     $78, !9
        153        ASSIGN                                                       !10, ~79
   67   154        INIT_FCALL                                                   'number_format'
        155        SEND_VAR                                                     !10
        156        SEND_VAL                                                     5
        157        DO_ICALL                                             $81     
        158        CONCAT                                               ~82     'load+in+', $81
        159        CONCAT                                               ~83     ~82, 'ms'
        160        CONCAT                                               ~84     ~83, '%0A'
        161        CONCAT                                               ~85     ~84, '%0A'
        162        ECHO                                                         ~85
   68   163        ECHO                                                         'pcre_stristr%28%29+x1000%0A'
   69   164        INIT_FCALL                                                   'microtime'
        165        SEND_VAL                                                     <true>
        166        DO_ICALL                                             $86     
        167        ASSIGN                                                       !9, $86
   70   168      > FE_RESET_R                                           $88     !2, ->175
        169    > > FE_FETCH_R                                                   $88, !7, ->175
   71   170    >   INIT_FCALL                                                   'pcre_stristr'
        171        SEND_VAR                                                     !0
        172        SEND_VAR                                                     !7
        173        DO_FCALL                                          0          
   70   174      > JMP                                                          ->169
        175    >   FE_FREE                                                      $88
   73   176        INIT_FCALL                                                   'microtime'
        177        SEND_VAL                                                     <true>
        178        DO_ICALL                                             $90     
        179        SUB                                                  ~91     $90, !9
        180        ASSIGN                                                       !11, ~91
   74   181        INIT_FCALL                                                   'number_format'
        182        SEND_VAR                                                     !11
        183        SEND_VAL                                                     5
        184        DO_ICALL                                             $93     
        185        CONCAT                                               ~94     'load+in+', $93
        186        CONCAT                                               ~95     ~94, 'ms'
        187        CONCAT                                               ~96     ~95, '%0A'
        188        CONCAT                                               ~97     ~96, '%0A'
        189        ECHO                                                         ~97
   75   190        INIT_FCALL                                                   'number_format'
        191        DIV                                                  ~98     !11, !10
        192        MUL                                                  ~99     ~98, 100
        193        SUB                                                  ~100    100, ~99
        194        SEND_VAL                                                     ~100
        195        SEND_VAL                                                     2
        196        DO_ICALL                                             $101    
        197        CONCAT                                               ~102    'time+save+', $101
        198        CONCAT                                               ~103    ~102, '%25'
        199        ECHO                                                         ~103
   76   200      > 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 = 45
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 44
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 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
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 = 43
Branch analysis from position: 43
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 8
filename:       /in/d8IAo
function name:  pcre_stristr
number of ops:  47
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, ->45
    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, ->44
    8    27    > > JMPZ                                                         !2, ->32
    9    28    >   FETCH_DIM_R                                          ~17     !4, 0
         29        FETCH_DIM_R                                          ~18     ~17, 0
         30        ASSIGN                                                       !3, ~18
    8    31      > JMP                                                          ->43
   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
   12    37      > JMP                                                          ->43
   16    38    >   FETCH_DIM_R                                          ~24     !4, 0
         39        FETCH_DIM_R                                          ~25     ~24, 0
         40        STRLEN                                               ~26     ~25
         41        FRAMELESS_ICALL_2                substr              ~27     !0, ~26
         42        ASSIGN                                                       !3, ~27
    7    43    > > JMP                                                          ->45
   21    44    >   ASSIGN                                                       !3, <false>
   24    45    > > RETURN                                                       !3
   25    46*     > RETURN                                                       null

End of function pcre_stristr

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.67 ms | 1980 KiB | 29 Q