3v4l.org

run code in 300+ PHP versions simultaneously
<?php function set_url_scheme( $url ) { return 'https://' . $url; } function get_home_url( $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[ 'scheme' ] ) or $result .= $current_site[ 'scheme' ] . '://'; 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 .= untrailingslashit( "/{$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 set_url_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/ALGHm
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     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/ALGHm
function name:  set_url_scheme
number of ops:  4
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        CONCAT                                           ~1      'https%3A%2F%2F', !0
          2      > RETURN                                                   ~1
    6     3*     > 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/ALGHm
function name:  get_home_url
number of ops:  3
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1      > RETURN                                                   'https%3A%2F%2Fsome.sub.domain.com%2Ffoo'
   11     2*     > 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 = 22
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 47) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
2 jumps found. (Code = 47) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
2 jumps found. (Code = 47) Position 1 = 45, Position 2 = 50
Branch analysis from position: 45
2 jumps found. (Code = 47) Position 1 = 52, Position 2 = 60
Branch analysis from position: 52
2 jumps found. (Code = 47) Position 1 = 62, Position 2 = 67
Branch analysis from position: 62
2 jumps found. (Code = 47) Position 1 = 69, Position 2 = 74
Branch analysis from position: 69
2 jumps found. (Code = 47) Position 1 = 76, Position 2 = 81
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
Branch analysis from position: 74
Branch analysis from position: 67
Branch analysis from position: 60
Branch analysis from position: 50
Branch analysis from position: 43
Branch analysis from position: 37
Branch analysis from position: 34
Branch analysis from position: 27
Branch analysis from position: 22
filename:       /in/ALGHm
function name:  multisite_url
number of ops:  86
compiled vars:  !0 = $url, !1 = $stage_url, !2 = $current_site, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     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
   16     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
   18    15        ASSIGN                                                   !3, ''
   19    16        ISSET_ISEMPTY_DIM_OBJ                         1  ~12     !2, 'scheme'
         17      > JMPNZ_EX                                         ~12     ~12, ->22
         18    >   FETCH_DIM_R                                      ~13     !2, 'scheme'
         19        CONCAT                                           ~14     ~13, '%3A%2F%2F'
         20        ASSIGN_OP                                     8  ~15     !3, ~14
         21        BOOL                                             ~12     ~15
   20    22    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~16     !2, 'user'
         23      > JMPNZ_EX                                         ~16     ~16, ->27
         24    >   FETCH_DIM_R                                      ~17     !2, 'user'
         25        ASSIGN_OP                                     8  ~18     !3, ~17
         26        BOOL                                             ~16     ~18
   21    27    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~19     !2, 'pass'
         28      > JMPNZ_EX                                         ~19     ~19, ->34
         29    >   NOP                                                      
         30        FETCH_DIM_R                                      ~20     !2, 'pass'
         31        FAST_CONCAT                                      ~21     '%3A', ~20
         32        ASSIGN_OP                                     8  ~22     !3, ~21
         33        BOOL                                             ~19     ~22
   22    34    > > JMPZ_EX                                          ~23     !3, ->37
         35    >   ASSIGN_OP                                     8  ~24     !3, '%40'
         36        BOOL                                             ~23     ~24
   23    37    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~25     !2, 'host'
         38      > JMPNZ_EX                                         ~25     ~25, ->43
         39    >   FETCH_DIM_R                                      ~26     !2, 'host'
         40        CAST                                          6  ~27     ~26
         41        ASSIGN_OP                                     8  ~28     !3, ~27
         42        BOOL                                             ~25     ~28
   24    43    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~29     !2, 'port'
         44      > JMPNZ_EX                                         ~29     ~29, ->50
         45    >   NOP                                                      
         46        FETCH_DIM_R                                      ~30     !2, 'port'
         47        FAST_CONCAT                                      ~31     '%3A', ~30
         48        ASSIGN_OP                                     8  ~32     !3, ~31
         49        BOOL                                             ~29     ~32
   25    50    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~33     !2, 'path'
         51      > JMPNZ_EX                                         ~33     ~33, ->60
         52    >   INIT_FCALL_BY_NAME                                       'untrailingslashit'
         53        NOP                                                      
         54        FETCH_DIM_R                                      ~34     !2, 'path'
         55        FAST_CONCAT                                      ~35     '%2F', ~34
         56        SEND_VAL_EX                                              ~35
         57        DO_FCALL                                      0  $36     
         58        ASSIGN_OP                                     8  ~37     !3, $36
         59        BOOL                                             ~33     ~37
   26    60    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~38     !1, 'path'
         61      > JMPNZ_EX                                         ~38     ~38, ->67
         62    >   NOP                                                      
         63        FETCH_DIM_R                                      ~39     !2, 'path'
         64        FAST_CONCAT                                      ~40     '%2F', ~39
         65        ASSIGN_OP                                     8  ~41     !3, ~40
         66        BOOL                                             ~38     ~41
   27    67    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~42     !1, 'query'
         68      > JMPNZ_EX                                         ~42     ~42, ->74
         69    >   NOP                                                      
         70        FETCH_DIM_R                                      ~43     !2, 'query'
         71        FAST_CONCAT                                      ~44     '%3F', ~43
         72        ASSIGN_OP                                     8  ~45     !3, ~44
         73        BOOL                                             ~42     ~45
   28    74    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~46     !1, 'fragment'
         75      > JMPNZ_EX                                         ~46     ~46, ->81
         76    >   NOP                                                      
         77        FETCH_DIM_R                                      ~47     !2, 'fragment'
         78        FAST_CONCAT                                      ~48     '%23', ~47
         79        ASSIGN_OP                                     8  ~49     !3, ~48
         80        BOOL                                             ~46     ~49
   30    81    >   INIT_FCALL                                               'set_url_scheme'
         82        SEND_VAR                                                 !3
         83        DO_FCALL                                      0  $50     
         84      > RETURN                                                   $50
   31    85*     > RETURN                                                   null

End of function multisite_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.63 ms | 1407 KiB | 20 Q