3v4l.org

run code in 300+ PHP versions simultaneously
<?php function startsWith($haystack, $needle) { return $needle === "" || strpos($haystack, $needle) === 0; } $haystack = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $a = null; $b = null; $c = null; $t = microtime(true); for($i = 0; $i < 1000000; $i++) { $a = startsWith($haystack, '789'); $b = startsWith($haystack, 'aaa'); $c = startsWith($haystack, 'abc'); } echo sprintf("took %.6f second(s)", microtime(true) - $t);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 10
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 10
Branch analysis from position: 28
Branch analysis from position: 10
filename:       /in/f5BHR
function name:  (null)
number of ops:  38
compiled vars:  !0 = $haystack, !1 = $a, !2 = $b, !3 = $c, !4 = $t, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
    7     1        ASSIGN                                                   !1, null
    8     2        ASSIGN                                                   !2, null
    9     3        ASSIGN                                                   !3, null
   10     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !4, $10
   11     8        ASSIGN                                                   !5, 0
          9      > JMP                                                      ->26
   12    10    >   INIT_FCALL                                               'startswith'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '789'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !1, $13
   13    15        INIT_FCALL                                               'startswith'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 'aaa'
         18        DO_FCALL                                      0  $15     
         19        ASSIGN                                                   !2, $15
   14    20        INIT_FCALL                                               'startswith'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 'abc'
         23        DO_FCALL                                      0  $17     
         24        ASSIGN                                                   !3, $17
   11    25        PRE_INC                                                  !5
         26    >   IS_SMALLER                                               !5, 1000000
         27      > JMPNZ                                                    ~20, ->10
   16    28    >   INIT_FCALL                                               'sprintf'
         29        SEND_VAL                                                 'took+%25.6f+second%28s%29'
         30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $21     
         33        SUB                                              ~22     $21, !4
         34        SEND_VAL                                                 ~22
         35        DO_ICALL                                         $23     
         36        ECHO                                                     $23
         37      > RETURN                                                   1

Function startswith:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/f5BHR
function name:  startsWith
number of ops:  12
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, ->10
          4    >   INIT_FCALL                                               'strpos'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8        IS_IDENTICAL                                     ~4      $3, 0
          9        BOOL                                             ~2      ~4
         10    > > RETURN                                                   ~2
    5    11*     > RETURN                                                   null

End of function startswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.82 ms | 1403 KiB | 22 Q