3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_str_contain($string, $keyword){ if(empty($string) || empty($keyword)) return false; $keyword_first_char = $keyword[0]; $keyword_length = strlen($keyword); $string_length = strlen($string); if( $string_length < $keyword_length ) return false; if( $string_length == $keyword_length ){ if($string == $keyword) return true; else return false; } if($keyword_length > 1){ for( $i=0; $i < $string_length; $i++){ //check if keyword's first char == string's first char if( $keyword_first_char == $string[$i] ){ $match = 1; for($j = 1; $j < $keyword_length; $j++){ if( ($i+$j < $string_length) && $keyword[$j] == $string[$i+$j] ){ $match++; } } if($match == $keyword_length){ return true; } } } } if($keyword_length == 1){ for( $i=0; $i < $string_length; $i++){ //check if keyword's first char == string's first char if( $keyword_first_char == $string[$i] ){ return true; } } } return false; } var_dump(is_str_contain("test", "t")); //true var_dump(is_str_contain("test", "")); //false var_dump(is_str_contain("test", "test")); //true var_dump(is_str_contain("test", "testa")); //flase var_dump(is_str_contain("a----z", "a")); //true var_dump(is_str_contain("a----z", "z")); //true
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/643Dc
function name:  (null)
number of ops:  43
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'is_str_contain'
          2        SEND_VAL                                                 'test'
          3        SEND_VAL                                                 't'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   51     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'is_str_contain'
          9        SEND_VAL                                                 'test'
         10        SEND_VAL                                                 ''
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   52    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'is_str_contain'
         16        SEND_VAL                                                 'test'
         17        SEND_VAL                                                 'test'
         18        DO_FCALL                                      0  $4      
         19        SEND_VAR                                                 $4
         20        DO_ICALL                                                 
   53    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'is_str_contain'
         23        SEND_VAL                                                 'test'
         24        SEND_VAL                                                 'testa'
         25        DO_FCALL                                      0  $6      
         26        SEND_VAR                                                 $6
         27        DO_ICALL                                                 
   54    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'is_str_contain'
         30        SEND_VAL                                                 'a----z'
         31        SEND_VAL                                                 'a'
         32        DO_FCALL                                      0  $8      
         33        SEND_VAR                                                 $8
         34        DO_ICALL                                                 
   55    35        INIT_FCALL                                               'var_dump'
         36        INIT_FCALL                                               'is_str_contain'
         37        SEND_VAL                                                 'a----z'
         38        SEND_VAL                                                 'z'
         39        DO_FCALL                                      0  $10     
         40        SEND_VAR                                                 $10
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Function is_str_contain:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 53
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 28
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 64
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 57
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 57
Branch analysis from position: 64
Branch analysis from position: 57
Branch analysis from position: 64
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 50
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 34
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 50
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 28
Branch analysis from position: 53
Branch analysis from position: 28
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 44
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 34
Branch analysis from position: 47
Branch analysis from position: 34
Branch analysis from position: 44
Branch analysis from position: 42
Branch analysis from position: 50
Branch analysis from position: 53
Branch analysis from position: 6
filename:       /in/643Dc
function name:  is_str_contain
number of ops:  66
compiled vars:  !0 = $string, !1 = $keyword, !2 = $keyword_first_char, !3 = $keyword_length, !4 = $string_length, !5 = $i, !6 = $match, !7 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ISSET_ISEMPTY_CV                                 ~8      !0
          3      > JMPNZ_EX                                         ~8      ~8, ->6
          4    >   ISSET_ISEMPTY_CV                                 ~9      !1
          5        BOOL                                             ~8      ~9
          6    > > JMPZ                                                     ~8, ->8
    5     7    > > RETURN                                                   <false>
    6     8    >   FETCH_DIM_R                                      ~10     !1, 0
          9        ASSIGN                                                   !2, ~10
    7    10        STRLEN                                           ~12     !1
         11        ASSIGN                                                   !3, ~12
    8    12        STRLEN                                           ~14     !0
         13        ASSIGN                                                   !4, ~14
   10    14        IS_SMALLER                                               !4, !3
         15      > JMPZ                                                     ~16, ->17
   11    16    > > RETURN                                                   <false>
   13    17    >   IS_EQUAL                                                 !4, !3
         18      > JMPZ                                                     ~17, ->24
   14    19    >   IS_EQUAL                                                 !0, !1
         20      > JMPZ                                                     ~18, ->23
   15    21    > > RETURN                                                   <true>
         22*       JMP                                                      ->24
   17    23    > > RETURN                                                   <false>
   21    24    >   IS_SMALLER                                               1, !3
         25      > JMPZ                                                     ~19, ->53
   22    26    >   ASSIGN                                                   !5, 0
         27      > JMP                                                      ->51
   24    28    >   FETCH_DIM_R                                      ~21     !0, !5
         29        IS_EQUAL                                                 !2, ~21
         30      > JMPZ                                                     ~22, ->50
   25    31    >   ASSIGN                                                   !6, 1
   26    32        ASSIGN                                                   !7, 1
         33      > JMP                                                      ->45
   27    34    >   ADD                                              ~25     !5, !7
         35        IS_SMALLER                                       ~26     ~25, !4
         36      > JMPZ_EX                                          ~26     ~26, ->42
         37    >   FETCH_DIM_R                                      ~27     !1, !7
         38        ADD                                              ~28     !5, !7
         39        FETCH_DIM_R                                      ~29     !0, ~28
         40        IS_EQUAL                                         ~30     ~27, ~29
         41        BOOL                                             ~26     ~30
         42    > > JMPZ                                                     ~26, ->44
   28    43    >   PRE_INC                                                  !6
   26    44    >   PRE_INC                                                  !7
         45    >   IS_SMALLER                                               !7, !3
         46      > JMPNZ                                                    ~33, ->34
   31    47    >   IS_EQUAL                                                 !6, !3
         48      > JMPZ                                                     ~34, ->50
   32    49    > > RETURN                                                   <true>
   22    50    >   PRE_INC                                                  !5
         51    >   IS_SMALLER                                               !5, !4
         52      > JMPNZ                                                    ~36, ->28
   39    53    >   IS_EQUAL                                                 !3, 1
         54      > JMPZ                                                     ~37, ->64
   40    55    >   ASSIGN                                                   !5, 0
         56      > JMP                                                      ->62
   42    57    >   FETCH_DIM_R                                      ~39     !0, !5
         58        IS_EQUAL                                                 !2, ~39
         59      > JMPZ                                                     ~40, ->61
   43    60    > > RETURN                                                   <true>
   40    61    >   PRE_INC                                                  !5
         62    >   IS_SMALLER                                               !5, !4
         63      > JMPNZ                                                    ~42, ->57
   47    64    > > RETURN                                                   <false>
   48    65*     > RETURN                                                   null

End of function is_str_contain

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.65 ms | 1411 KiB | 21 Q