3v4l.org

run code in 300+ PHP versions simultaneously
<?php function set_url_scheme( $url ) { return str_replace('http:', 'https:', $url); } function get_home_url() { return 'https://some.sub.domain.com/foo'; } function multisite_url( $url ) { $stage_url = parse_url( $url ) ?: []; $current_site = parse_url( get_home_url() ) ?: []; $result = ''; empty ( $current_site[ 'user' ] ) or $result .= $current_site[ 'user' ]; empty ( $current_site[ 'pass' ] ) or $result .= ":{$current_site['pass']}"; $result and $result .= '@'; empty ( $current_site[ 'host' ] ) or $result .= "{$current_site['host']}"; empty ( $current_site[ 'port' ] ) or $result .= ":{$current_site['port']}"; empty ( $current_site[ 'path' ] ) or $result .= rtrim( "/{$current_site['path']}", '/' ); empty ( $stage_url[ 'path' ] ) or $result .= "/{$current_site['path']}"; empty ( $stage_url[ 'query' ] ) or $result .= "?{$current_site['query']}"; empty ( $stage_url[ 'fragment' ] ) or $result .= "#{$current_site['fragment']}"; return empty ( $current_site[ 'scheme' ] ) ? set_url_scheme( $result ) : "{$current_site[ 'scheme' ]}://{$result}"; } var_dump( multisite_url('https://maindomain.com') );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lNob
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'multisite_url'
          2        SEND_VAL                                                 'https%3A%2F%2Fmaindomain.com'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function set_url_scheme:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lNob
function name:  set_url_scheme
number of ops:  8
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 'http%3A'
          3        SEND_VAL                                                 'https%3A'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
    8     7*     > RETURN                                                   null

End of function set_url_scheme

Function get_home_url:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3lNob
function name:  get_home_url
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   'https%3A%2F%2Fsome.sub.domain.com%2Ffoo'
   13     1*     > RETURN                                                   null

End of function get_home_url

Function multisite_url:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 47) Position 1 = 33, Position 2 = 37
Branch analysis from position: 33
2 jumps found. (Code = 47) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
2 jumps found. (Code = 47) Position 1 = 46, Position 2 = 55
Branch analysis from position: 46
2 jumps found. (Code = 47) Position 1 = 57, Position 2 = 62
Branch analysis from position: 57
2 jumps found. (Code = 47) Position 1 = 64, Position 2 = 69
Branch analysis from position: 64
2 jumps found. (Code = 47) Position 1 = 71, Position 2 = 76
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 83
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 88
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
Branch analysis from position: 69
Branch analysis from position: 62
Branch analysis from position: 55
Branch analysis from position: 44
Branch analysis from position: 37
Branch analysis from position: 31
Branch analysis from position: 28
Branch analysis from position: 21
filename:       /in/3lNob
function name:  multisite_url
number of ops:  90
compiled vars:  !0 = $url, !1 = $stage_url, !2 = $current_site, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'parse_url'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        JMP_SET                                          ~5      $4, ->6
          5        QM_ASSIGN                                        ~5      <array>
          6        ASSIGN                                                   !1, ~5
   18     7        INIT_FCALL                                               'parse_url'
          8        INIT_FCALL                                               'get_home_url'
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                         $8      
         12        JMP_SET                                          ~9      $8, ->14
         13        QM_ASSIGN                                        ~9      <array>
         14        ASSIGN                                                   !2, ~9
   20    15        ASSIGN                                                   !3, ''
   21    16        ISSET_ISEMPTY_DIM_OBJ                         1  ~12     !2, 'user'
         17      > JMPNZ_EX                                         ~12     ~12, ->21
         18    >   FETCH_DIM_R                                      ~13     !2, 'user'
         19        ASSIGN_OP                                     8  ~14     !3, ~13
         20        BOOL                                             ~12     ~14
   22    21    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~15     !2, 'pass'
         22      > JMPNZ_EX                                         ~15     ~15, ->28
         23    >   NOP                                                      
         24        FETCH_DIM_R                                      ~16     !2, 'pass'
         25        FAST_CONCAT                                      ~17     '%3A', ~16
         26        ASSIGN_OP                                     8  ~18     !3, ~17
         27        BOOL                                             ~15     ~18
   23    28    > > JMPZ_EX                                          ~19     !3, ->31
         29    >   ASSIGN_OP                                     8  ~20     !3, '%40'
         30        BOOL                                             ~19     ~20
   24    31    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~21     !2, 'host'
         32      > JMPNZ_EX                                         ~21     ~21, ->37
         33    >   FETCH_DIM_R                                      ~22     !2, 'host'
         34        CAST                                          6  ~23     ~22
         35        ASSIGN_OP                                     8  ~24     !3, ~23
         36        BOOL                                             ~21     ~24
   25    37    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~25     !2, 'port'
         38      > JMPNZ_EX                                         ~25     ~25, ->44
         39    >   NOP                                                      
         40        FETCH_DIM_R                                      ~26     !2, 'port'
         41        FAST_CONCAT                                      ~27     '%3A', ~26
         42        ASSIGN_OP                                     8  ~28     !3, ~27
         43        BOOL                                             ~25     ~28
   26    44    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~29     !2, 'path'
         45      > JMPNZ_EX                                         ~29     ~29, ->55
         46    >   INIT_FCALL                                               'rtrim'
         47        NOP                                                      
         48        FETCH_DIM_R                                      ~30     !2, 'path'
         49        FAST_CONCAT                                      ~31     '%2F', ~30
         50        SEND_VAL                                                 ~31
         51        SEND_VAL                                                 '%2F'
         52        DO_ICALL                                         $32     
         53        ASSIGN_OP                                     8  ~33     !3, $32
         54        BOOL                                             ~29     ~33
   27    55    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~34     !1, 'path'
         56      > JMPNZ_EX                                         ~34     ~34, ->62
         57    >   NOP                                                      
         58        FETCH_DIM_R                                      ~35     !2, 'path'
         59        FAST_CONCAT                                      ~36     '%2F', ~35
         60        ASSIGN_OP                                     8  ~37     !3, ~36
         61        BOOL                                             ~34     ~37
   28    62    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~38     !1, 'query'
         63      > JMPNZ_EX                                         ~38     ~38, ->69
         64    >   NOP                                                      
         65        FETCH_DIM_R                                      ~39     !2, 'query'
         66        FAST_CONCAT                                      ~40     '%3F', ~39
         67        ASSIGN_OP                                     8  ~41     !3, ~40
         68        BOOL                                             ~38     ~41
   29    69    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~42     !1, 'fragment'
         70      > JMPNZ_EX                                         ~42     ~42, ->76
         71    >   NOP                                                      
         72        FETCH_DIM_R                                      ~43     !2, 'fragment'
         73        FAST_CONCAT                                      ~44     '%23', ~43
         74        ASSIGN_OP                                     8  ~45     !3, ~44
         75        BOOL                                             ~42     ~45
   31    76    >   ISSET_ISEMPTY_DIM_OBJ                         1          !2, 'scheme'
         77      > JMPZ                                                     ~46, ->83
   32    78    >   INIT_FCALL                                               'set_url_scheme'
         79        SEND_VAR                                                 !3
         80        DO_FCALL                                      0  $47     
         81        QM_ASSIGN                                        ~48     $47
         82      > JMP                                                      ->88
   33    83    >   FETCH_DIM_R                                      ~49     !2, 'scheme'
         84        ROPE_INIT                                     3  ~51     ~49
         85        ROPE_ADD                                      1  ~51     ~51, '%3A%2F%2F'
         86        ROPE_END                                      2  ~50     ~51, !3
         87        QM_ASSIGN                                        ~48     ~50
         88    > > RETURN                                                   ~48
   34    89*     > RETURN                                                   null

End of function multisite_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.4 ms | 1407 KiB | 24 Q