3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function stringContains(string $needle, string $haystack): bool { return strpos($haystack, $needle) !== false; } assert(stringContains('Ahoy', 'Ahoy World!') === true); assert(stringContains('Hello', 'Ahoy World!') === false); function stringStartsWith(string $needle, string $haystack): bool { return strpos($haystack, $needle) === 0; } assert(stringStartsWith('Ahoy', 'Ahoy World!') === true); assert(stringStartsWith('Hello', 'AhoyWorld') === false); function stringEndsWith(string $needle, string $haystack): bool { return strpos($haystack, $needle) === strlen($haystack) - strlen($needle); } assert(stringEndsWith('World!', 'Ahoy World!') === true); assert(stringEndsWith('Ahoy', 'Ahoy World!') === false);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QWFZ3
function name:  (null)
number of ops:  61
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSERT_CHECK                                             
          1        INIT_FCALL                                               'assert'
          2        INIT_FCALL                                               'stringcontains'
          3        SEND_VAL                                                 'Ahoy'
          4        SEND_VAL                                                 'Ahoy+World%21'
          5        DO_FCALL                                      0  $0      
          6        TYPE_CHECK                                    8  ~1      $0
          7        SEND_VAL                                                 ~1
          8        SEND_VAL                                                 'assert%28stringContains%28%27Ahoy%27%2C+%27Ahoy+World%21%27%29+%3D%3D%3D+true%29'
          9        DO_ICALL                                                 
   10    10        ASSERT_CHECK                                             
         11        INIT_FCALL                                               'assert'
         12        INIT_FCALL                                               'stringcontains'
         13        SEND_VAL                                                 'Hello'
         14        SEND_VAL                                                 'Ahoy+World%21'
         15        DO_FCALL                                      0  $3      
         16        TYPE_CHECK                                    4  ~4      $3
         17        SEND_VAL                                                 ~4
         18        SEND_VAL                                                 'assert%28stringContains%28%27Hello%27%2C+%27Ahoy+World%21%27%29+%3D%3D%3D+false%29'
         19        DO_ICALL                                                 
   16    20        ASSERT_CHECK                                             
         21        INIT_FCALL                                               'assert'
         22        INIT_FCALL                                               'stringstartswith'
         23        SEND_VAL                                                 'Ahoy'
         24        SEND_VAL                                                 'Ahoy+World%21'
         25        DO_FCALL                                      0  $6      
         26        TYPE_CHECK                                    8  ~7      $6
         27        SEND_VAL                                                 ~7
         28        SEND_VAL                                                 'assert%28stringStartsWith%28%27Ahoy%27%2C+%27Ahoy+World%21%27%29+%3D%3D%3D+true%29'
         29        DO_ICALL                                                 
   17    30        ASSERT_CHECK                                             
         31        INIT_FCALL                                               'assert'
         32        INIT_FCALL                                               'stringstartswith'
         33        SEND_VAL                                                 'Hello'
         34        SEND_VAL                                                 'AhoyWorld'
         35        DO_FCALL                                      0  $9      
         36        TYPE_CHECK                                    4  ~10     $9
         37        SEND_VAL                                                 ~10
         38        SEND_VAL                                                 'assert%28stringStartsWith%28%27Hello%27%2C+%27AhoyWorld%27%29+%3D%3D%3D+false%29'
         39        DO_ICALL                                                 
   23    40        ASSERT_CHECK                                             
         41        INIT_FCALL                                               'assert'
         42        INIT_FCALL                                               'stringendswith'
         43        SEND_VAL                                                 'World%21'
         44        SEND_VAL                                                 'Ahoy+World%21'
         45        DO_FCALL                                      0  $12     
         46        TYPE_CHECK                                    8  ~13     $12
         47        SEND_VAL                                                 ~13
         48        SEND_VAL                                                 'assert%28stringEndsWith%28%27World%21%27%2C+%27Ahoy+World%21%27%29+%3D%3D%3D+true%29'
         49        DO_ICALL                                                 
   24    50        ASSERT_CHECK                                             
         51        INIT_FCALL                                               'assert'
         52        INIT_FCALL                                               'stringendswith'
         53        SEND_VAL                                                 'Ahoy'
         54        SEND_VAL                                                 'Ahoy+World%21'
         55        DO_FCALL                                      0  $15     
         56        TYPE_CHECK                                    4  ~16     $15
         57        SEND_VAL                                                 ~16
         58        SEND_VAL                                                 'assert%28stringEndsWith%28%27Ahoy%27%2C+%27Ahoy+World%21%27%29+%3D%3D%3D+false%29'
         59        DO_ICALL                                                 
         60      > RETURN                                                   1

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

End of function stringcontains

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

End of function stringstartswith

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

End of function stringendswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.71 ms | 1407 KiB | 23 Q