3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Find substring starting in string, starting from some symbol(s) * @param string $haystack * @param string $needle * @return string */ function my_strstr(string $haystack, string $needle): string { for($i = 0; $i < strlen($haystack); $i++) { if($haystack[$i] == $needle[0]) { $eq = true; for($j = 0; $j < strlen($needle); $j++) { if($haystack[$i + $j] !== $needle[$j]) { $eq = false; break; } } if($eq) { return substr($haystack, $i); } } } } var_dump(my_strstr('asdfghend', 'fg')); // 'fghend';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e2TB2
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'my_strstr'
          2        SEND_VAL                                                     'asdfghend'
          3        SEND_VAL                                                     'fg'
          4        DO_FCALL                                          0  $0      
          5        SEND_VAR                                                     $0
          6        DO_ICALL                                                     
          7      > RETURN                                                       1

Function my_strstr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 4
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 11
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 4
Branch analysis from position: 30
Branch analysis from position: 4
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 11
Branch analysis from position: 22
Branch analysis from position: 11
Branch analysis from position: 26
filename:       /in/e2TB2
function name:  my_strstr
number of ops:  32
compiled vars:  !0 = $haystack, !1 = $needle, !2 = $i, !3 = $eq, !4 = $j
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   11     2        ASSIGN                                                       !2, 0
          3      > JMP                                                          ->27
   12     4    >   FETCH_DIM_R                                          ~6      !0, !2
          5        FETCH_DIM_R                                          ~7      !1, 0
          6        IS_EQUAL                                                     ~6, ~7
          7      > JMPZ                                                         ~8, ->26
   13     8    >   ASSIGN                                                       !3, <true>
   14     9        ASSIGN                                                       !4, 0
         10      > JMP                                                          ->19
   15    11    >   ADD                                                  ~11     !2, !4
         12        FETCH_DIM_R                                          ~12     !0, ~11
         13        FETCH_DIM_R                                          ~13     !1, !4
         14        IS_NOT_IDENTICAL                                             ~12, ~13
         15      > JMPZ                                                         ~14, ->18
   16    16    >   ASSIGN                                                       !3, <false>
   17    17      > JMP                                                          ->22
   14    18    >   PRE_INC                                                      !4
         19    >   STRLEN                                               ~17     !1
         20        IS_SMALLER                                                   !4, ~17
         21      > JMPNZ                                                        ~18, ->11
   20    22    > > JMPZ                                                         !3, ->26
   21    23    >   FRAMELESS_ICALL_2                substr              ~19     !0, !2
         24        VERIFY_RETURN_TYPE                                           ~19
         25      > RETURN                                                       ~19
   11    26    >   PRE_INC                                                      !2
         27    >   STRLEN                                               ~21     !0
         28        IS_SMALLER                                                   !2, ~21
         29      > JMPNZ                                                        ~22, ->4
   25    30    >   VERIFY_RETURN_TYPE                                           
         31      > RETURN                                                       null

End of function my_strstr

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.16 ms | 1718 KiB | 15 Q