3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo($path) { if ($path && $path[0] = '/') { $path = substr($path, 1); } $url = 'http://' . 'www.example.com/' . $path; echo $url, PHP_EOL; return $url; } foo('/abc'); foo('abc'); foo('/'); foo('');
based on 9clh3
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/KAb7K
function name:  (null)
number of ops:  14
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
  10     1        INIT_FCALL                                               'foo'
         2        SEND_VAL                                                 '%2Fabc'
         3        DO_FCALL                                      0          
  11     4        INIT_FCALL                                               'foo'
         5        SEND_VAL                                                 'abc'
         6        DO_FCALL                                      0          
  12     7        INIT_FCALL                                               'foo'
         8        SEND_VAL                                                 '%2F'
         9        DO_FCALL                                      0          
  13    10        INIT_FCALL                                               'foo'
        11        SEND_VAL                                                 ''
        12        DO_FCALL                                      0          
        13      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
Jump found. Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
Jump found. Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 5
filename:       /in/KAb7K
function name:  foo
number of ops:  17
compiled vars:  !0 = $path, !1 = $url
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   RECV                                             !0      
   3     1      > JMPZ_EX                                          ~2      !0, ->5
         2    >   ASSIGN_DIM                                       $3      !0, 0
         3        OP_DATA                                                  '%2F'
         4        BOOL                                             ~2      $3
         5    > > JMPZ                                                     ~2, ->11
   4     6    >   INIT_FCALL                                               'substr'
         7        SEND_VAR                                                 !0
         8        SEND_VAL                                                 1
         9        DO_ICALL                                         $4      
        10        ASSIGN                                                   !0, $4
   6    11    >   CONCAT                                           ~6      'http%3A%2F%2Fwww.example.com%2F', !0
        12        ASSIGN                                                   !1, ~6
   7    13        ECHO                                                     !1
        14        ECHO                                                     '%0A'
   8    15      > RETURN                                                   !1
   9    16*     > RETURN                                                   null

End of function foo

Generated using Vulcan Logic Dumper, using php 7.3.0