3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function endswith($haystack, $needle) { $length = strlen($needle); if ($length == 0) { return true; } return (substr($haystack, -$length) === $needle); } if (version_compare(phpversion(), '5.1.0', '>')) { var_dump(endswith("abcdefg", "abc")); }
based on qGYBH
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/55ajg
function name:  (null)
number of ops:  17
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  12     1        INIT_FCALL                                               'version_compare'
         2        INIT_FCALL                                               'phpversion'
         3        DO_ICALL                                         $0      
         4        SEND_VAR                                                 $0
         5        SEND_VAL                                                 '5.1.0'
         6        SEND_VAL                                                 '%3E'
         7        DO_ICALL                                         $1      
         8      > JMPZ                                                     $1, ->16
  13     9    >   INIT_FCALL                                               'var_dump'
        10        INIT_FCALL                                               'endswith'
        11        SEND_VAL                                                 'abcdefg'
        12        SEND_VAL                                                 'abc'
        13        DO_FCALL                                      0  $2      
        14        SEND_VAR                                                 $2
        15        DO_ICALL                                                 
  14    16    > > RETURN                                                   1

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

End of function endswith

Generated using Vulcan Logic Dumper, using php 7.3.0