3v4l.org

run code in 300+ 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 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 4
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 29
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 = 29
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 4
Branch analysis from position: 33
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: 29
filename:       /in/e2TB2
function name:  my_strstr
number of ops:  35
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                                                      ->30
   12     4    >   FETCH_DIM_R                                      ~6      !0, !2
          5        FETCH_DIM_R                                      ~7      !1, 0
          6        IS_EQUAL                                                 ~6, ~7
          7      > JMPZ                                                     ~8, ->29
   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, ->29
   21    23    >   INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                         $19     
         27        VERIFY_RETURN_TYPE                                       $19
         28      > RETURN                                                   $19
   11    29    >   PRE_INC                                                  !2
         30    >   STRLEN                                           ~21     !0
         31        IS_SMALLER                                               !2, ~21
         32      > JMPNZ                                                    ~22, ->4
   25    33    >   VERIFY_RETURN_TYPE                                       
         34      > RETURN                                                   null

End of function my_strstr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.99 ms | 1013 KiB | 16 Q