3v4l.org

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

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

End of function endswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.99 ms | 1406 KiB | 24 Q