3v4l.org

run code in 300+ PHP versions simultaneously
<?php function endsWith($haystack, $needle) { return $needle === '' || substr_compare($haystack, $needle, -strlen($needle), strlen($needle)) === 0; } var_dump(endsWith('foobar', 'bar')); var_dump(endsWith('foobar', 'foo')); var_dump(endsWith('foobar', 'foobar')); var_dump(endsWith('foobar', 'foobarbaz')); var_dump(endsWith('foobar', 'xfoobar')); var_dump(endsWith('', '')); var_dump(endsWith('foo', '')); var_dump(endsWith('', 'foo'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GsP9T
function name:  (null)
number of ops:  57
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'endswith'
          2        SEND_VAL                                                 'foobar'
          3        SEND_VAL                                                 'bar'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
    8     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'endswith'
          9        SEND_VAL                                                 'foobar'
         10        SEND_VAL                                                 'foo'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
    9    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'endswith'
         16        SEND_VAL                                                 'foobar'
         17        SEND_VAL                                                 'foobar'
         18        DO_FCALL                                      0  $4      
         19        SEND_VAR                                                 $4
         20        DO_ICALL                                                 
   10    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'endswith'
         23        SEND_VAL                                                 'foobar'
         24        SEND_VAL                                                 'foobarbaz'
         25        DO_FCALL                                      0  $6      
         26        SEND_VAR                                                 $6
         27        DO_ICALL                                                 
   11    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'endswith'
         30        SEND_VAL                                                 'foobar'
         31        SEND_VAL                                                 'xfoobar'
         32        DO_FCALL                                      0  $8      
         33        SEND_VAR                                                 $8
         34        DO_ICALL                                                 
   12    35        INIT_FCALL                                               'var_dump'
         36        INIT_FCALL                                               'endswith'
         37        SEND_VAL                                                 ''
         38        SEND_VAL                                                 ''
         39        DO_FCALL                                      0  $10     
         40        SEND_VAR                                                 $10
         41        DO_ICALL                                                 
   13    42        INIT_FCALL                                               'var_dump'
         43        INIT_FCALL                                               'endswith'
         44        SEND_VAL                                                 'foo'
         45        SEND_VAL                                                 ''
         46        DO_FCALL                                      0  $12     
         47        SEND_VAR                                                 $12
         48        DO_ICALL                                                 
   14    49        INIT_FCALL                                               'var_dump'
         50        INIT_FCALL                                               'endswith'
         51        SEND_VAL                                                 ''
         52        SEND_VAL                                                 'foo'
         53        DO_FCALL                                      0  $14     
         54        SEND_VAR                                                 $14
         55        DO_ICALL                                                 
         56      > RETURN                                                   1

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

End of function endswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.95 ms | 1403 KiB | 25 Q