3v4l.org

run code in 300+ PHP versions simultaneously
<?php function joinPath() { $path = ''; $arguments = func_get_args(); $args = array(); foreach($arguments as $a) if($a !== '') $args[] = $a;//Removes the empty elements $arg_count = count($args); for($i=0; $i<$arg_count; $i++) { $folder = $args[$i]; if($i != 0 and $folder[0] == DIRECTORY_SEPARATOR) $folder = substr($folder,1); //Remove the first char if it is a '/' - and its not in the first argument if($i != $arg_count-1 and substr($folder,-1) == DIRECTORY_SEPARATOR) $folder = substr($folder,0,-1); //Remove the last char - if its not in the last argument $path .= $folder; if($i != $arg_count-1) $path .= DIRECTORY_SEPARATOR; //Add the '/' if its not the last element. } return $path; } print(joinPath("blah", "", "gda"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bahLX
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'joinpath'
          1        SEND_VAL                                                 'blah'
          2        SEND_VAL                                                 ''
          3        SEND_VAL                                                 'gda'
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
          6      > RETURN                                                   1

Function joinpath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 16
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 50
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 16
Branch analysis from position: 53
Branch analysis from position: 16
Branch analysis from position: 50
Branch analysis from position: 45
Branch analysis from position: 38
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 11
filename:       /in/bahLX
function name:  joinPath
number of ops:  55
compiled vars:  !0 = $path, !1 = $arguments, !2 = $args, !3 = $a, !4 = $arg_count, !5 = $i, !6 = $folder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, ''
    4     1        FUNC_GET_ARGS                                    ~8      
          2        ASSIGN                                                   !1, ~8
    5     3        ASSIGN                                                   !2, <array>
    6     4      > FE_RESET_R                                       $11     !1, ->11
          5    > > FE_FETCH_R                                               $11, !3, ->11
          6    >   IS_NOT_IDENTICAL                                         !3, ''
          7      > JMPZ                                                     ~12, ->10
          8    >   ASSIGN_DIM                                               !2
          9        OP_DATA                                                  !3
         10    > > JMP                                                      ->5
         11    >   FE_FREE                                                  $11
    8    12        COUNT                                            ~14     !2
         13        ASSIGN                                                   !4, ~14
    9    14        ASSIGN                                                   !5, 0
         15      > JMP                                                      ->51
   10    16    >   FETCH_DIM_R                                      ~17     !2, !5
         17        ASSIGN                                                   !6, ~17
   12    18        IS_NOT_EQUAL                                     ~19     !5, 0
         19      > JMPZ_EX                                          ~19     ~19, ->23
         20    >   FETCH_DIM_R                                      ~20     !6, 0
         21        IS_EQUAL                                         ~21     ~20, '%2F'
         22        BOOL                                             ~19     ~21
         23    > > JMPZ                                                     ~19, ->29
         24    >   INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !6
         26        SEND_VAL                                                 1
         27        DO_ICALL                                         $22     
         28        ASSIGN                                                   !6, $22
   13    29    >   SUB                                              ~24     !4, 1
         30        IS_NOT_EQUAL                                     ~25     !5, ~24
         31      > JMPZ_EX                                          ~25     ~25, ->38
         32    >   INIT_FCALL                                               'substr'
         33        SEND_VAR                                                 !6
         34        SEND_VAL                                                 -1
         35        DO_ICALL                                         $26     
         36        IS_EQUAL                                         ~27     $26, '%2F'
         37        BOOL                                             ~25     ~27
         38    > > JMPZ                                                     ~25, ->45
         39    >   INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !6
         41        SEND_VAL                                                 0
         42        SEND_VAL                                                 -1
         43        DO_ICALL                                         $28     
         44        ASSIGN                                                   !6, $28
   15    45    >   ASSIGN_OP                                     8          !0, !6
   16    46        SUB                                              ~31     !4, 1
         47        IS_NOT_EQUAL                                             !5, ~31
         48      > JMPZ                                                     ~32, ->50
         49    >   ASSIGN_OP                                     8          !0, '%2F'
    9    50    >   PRE_INC                                                  !5
         51    >   IS_SMALLER                                               !5, !4
         52      > JMPNZ                                                    ~35, ->16
   18    53    > > RETURN                                                   !0
   19    54*     > RETURN                                                   null

End of function joinpath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.43 ms | 1394 KiB | 16 Q