3v4l.org

run code in 300+ PHP versions simultaneously
<?php function startsWith($haystack, $needle) { $cutsQuantity = 2; $parts = explode($needle, $haystack, $cutsQuantity); return ($parts[0] === ''); } function endsWith($haystack, $needle) { $parts = explode($needle, $haystack); return (array_pop($parts) === ''); } var_dump(startsWith('The quick brown fox jumps over the lazy dog', 'The quick')); // true var_dump(startsWith('The quick brown fox jumps over the lazy dog', 'lazy dog')); // false var_dump(endsWith('The quick brown fox jumps over the lazy dog', 'The quick')); // false var_dump(endsWith('The quick brown fox jumps over the lázy dog', 'lázy dog')); // true
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gRggY
function name:  (null)
number of ops:  29
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'startswith'
          2        SEND_VAL                                                 'The+quick+brown+fox+jumps+over+the+lazy+dog'
          3        SEND_VAL                                                 'The+quick'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   15     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'startswith'
          9        SEND_VAL                                                 'The+quick+brown+fox+jumps+over+the+lazy+dog'
         10        SEND_VAL                                                 'lazy+dog'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   16    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'endswith'
         16        SEND_VAL                                                 'The+quick+brown+fox+jumps+over+the+lazy+dog'
         17        SEND_VAL                                                 'The+quick'
         18        DO_FCALL                                      0  $4      
         19        SEND_VAR                                                 $4
         20        DO_ICALL                                                 
   17    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'endswith'
         23        SEND_VAL                                                 'The+quick+brown+fox+jumps+over+the+l%C3%A1zy+dog'
         24        SEND_VAL                                                 'l%C3%A1zy+dog'
         25        DO_FCALL                                      0  $6      
         26        SEND_VAR                                                 $6
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

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

End of function startswith

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

End of function endswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.62 ms | 1007 KiB | 20 Q