3v4l.org

run code in 300+ PHP versions simultaneously
<?php function startsWith($haystack, $needle) { return $needle === "" || strpos($haystack, $needle) === 0; } $url = "http://www.domain.com/pages/images/apple.png"; $urlArr = explode('/', $url); echo (startsWith($url, 'http')) ? $urlArr[3] : $urlArr[1];
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M4o11
function name:  (null)
number of ops:  18
compiled vars:  !0 = $url, !1 = $urlArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.domain.com%2Fpages%2Fimages%2Fapple.png'
   10     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   12     6        INIT_FCALL                                               'startswith'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'http'
          9        DO_FCALL                                      0  $5      
         10      > JMPZ                                                     $5, ->14
         11    >   FETCH_DIM_R                                      ~6      !1, 3
         12        QM_ASSIGN                                        ~7      ~6
         13      > JMP                                                      ->16
         14    >   FETCH_DIM_R                                      ~8      !1, 1
         15        QM_ASSIGN                                        ~7      ~8
         16    >   ECHO                                                     ~7
         17      > 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/M4o11
function name:  startsWith
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        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
    6    11*     > RETURN                                                   null

End of function startswith

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.01 ms | 1390 KiB | 18 Q