3v4l.org

run code in 300+ PHP versions simultaneously
<?php function endswith($string, $test) { $strlen = strlen($string); $testlen = strlen($test); if ($testlen > $strlen) return false; return substr_compare($string, $test, -$testlen) === 0; } if(false == endswith('http://localhost/events/10','/events/')){ echo 'true'; } else{ echo 'false'; } $testlen = strlen('/bob/'); if(false == (substr_compare('http://localhost/events/10','/events/',-$testlen)===0)){ echo 'true'; } else{ echo 'false'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
Branch analysis from position: 21
filename:       /in/4VfFD
function name:  (null)
number of ops:  23
compiled vars:  !0 = $testlen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'endswith'
          1        SEND_VAL                                                 'http%3A%2F%2Flocalhost%2Fevents%2F10'
          2        SEND_VAL                                                 '%2Fevents%2F'
          3        DO_FCALL                                      0  $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->8
   13     6    >   ECHO                                                     'true'
          7      > JMP                                                      ->9
   16     8    >   ECHO                                                     'false'
   19     9    >   ASSIGN                                                   !0, 5
   20    10        INIT_FCALL                                               'substr_compare'
         11        SEND_VAL                                                 'http%3A%2F%2Flocalhost%2Fevents%2F10'
         12        SEND_VAL                                                 '%2Fevents%2F'
         13        MUL                                              ~4      !0, -1
         14        SEND_VAL                                                 ~4
         15        DO_ICALL                                         $5      
         16        IS_IDENTICAL                                     ~6      $5, 0
         17        BOOL_NOT                                         ~7      ~6
         18      > JMPZ                                                     ~7, ->21
   21    19    >   ECHO                                                     'true'
         20      > JMP                                                      ->22
   24    21    >   ECHO                                                     'false'
   25    22    > > RETURN                                                   1

Function endswith:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4VfFD
function name:  endswith
number of ops:  18
compiled vars:  !0 = $string, !1 = $test, !2 = $strlen, !3 = $testlen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        STRLEN                                           ~4      !0
          3        ASSIGN                                                   !2, ~4
    6     4        STRLEN                                           ~6      !1
          5        ASSIGN                                                   !3, ~6
    7     6        IS_SMALLER                                               !2, !3
          7      > JMPZ                                                     ~8, ->9
          8    > > RETURN                                                   <false>
    8     9    >   INIT_FCALL                                               'substr_compare'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        MUL                                              ~9      !3, -1
         13        SEND_VAL                                                 ~9
         14        DO_ICALL                                         $10     
         15        IS_IDENTICAL                                     ~11     $10, 0
         16      > RETURN                                                   ~11
    9    17*     > RETURN                                                   null

End of function endswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.43 ms | 1402 KiB | 16 Q