3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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') );
Output for 7.1.0 - 7.2.9
Fatal error: Uncaught ArgumentCountError: Too few arguments to function get_home_url(), 0 passed in /in/ALGHm on line 16 and exactly 1 expected in /in/ALGHm:8 Stack trace: #0 /in/ALGHm(16): get_home_url() #1 /in/ALGHm(33): multisite_url('https://maindom...') #2 {main} thrown in /in/ALGHm on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.31
Warning: Missing argument 1 for get_home_url(), called in /in/ALGHm on line 16 and defined in /in/ALGHm on line 8 Fatal error: Uncaught Error: Call to undefined function untrailingslashit() in /in/ALGHm:25 Stack trace: #0 /in/ALGHm(33): multisite_url('https://maindom...') #1 {main} thrown in /in/ALGHm on line 25
Process exited with code 255.
Output for hhvm-3.22.0
Warning: get_home_url() expects exactly 1 parameter, 0 given in /in/ALGHm on line -1 Fatal error: Uncaught Error: Call to undefined function untrailingslashit() in /in/ALGHm:-1 Stack trace: #0 /in/ALGHm(-1): multisite_url() #1 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.21.3
Warning: get_home_url() expects exactly 1 parameter, 0 given in /in/ALGHm on line 10 Fatal error: Uncaught Error: Call to undefined function untrailingslashit() in /in/ALGHm:25 Stack trace: #0 /in/ALGHm(33): multisite_url() #1 {main}
Process exited with code 255.
Output for 5.6.30
Warning: Missing argument 1 for get_home_url(), called in /in/ALGHm on line 16 and defined in /in/ALGHm on line 8 Fatal error: Call to undefined function untrailingslashit() in /in/ALGHm on line 25
Process exited with code 255.