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') );
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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.

preferences:
174.84 ms | 402 KiB | 211 Q