3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = '///example.com'; var_dump( wp_parse_url( $url ) ); $url = '://example.com'; var_dump( wp_parse_url( $url ) ); function wp_parse_url( $url ) { $parts = @parse_url( $url ); if ( ! $parts ) { // < PHP 5.4.7 compat, trouble with relative paths including a scheme break in the path if ( '/' == $url[0] && false !== strpos( $url, '://' ) ) { // Since we know it's a relative path, prefix with a scheme/host placeholder and try again if ( ! $parts = @parse_url( 'placeholder://placeholder' . $url ) ) { return $parts; } // Remove the placeholder values unset( $parts['scheme'], $parts['host'] ); } else { return $parts; } } // < PHP 5.4.7 compat, doesn't detect schemeless URL's host field if ( '//' == substr( $url, 0, 2 ) && ! isset( $parts['host'] ) ) { $path_parts = explode( '/', substr( $parts['path'], 2 ), 2 ); $parts['host'] = $path_parts[0]; if ( isset( $path_parts[1] ) ) { $parts['path'] = '/' . $path_parts[1]; } else { unset( $parts['path'] ); } } return $parts; }
Output for 5.4.7 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 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
bool(false) array(1) { ["path"]=> string(14) "://example.com" }
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 bool(false) array(1) { ["path"]=> string(14) "://example.com" }
Output for 5.3.6 - 5.3.29, 5.4.0 - 5.4.6
array(2) { ["path"]=> string(12) "/example.com" ["host"]=> string(0) "" } array(1) { ["path"]=> string(14) "://example.com" }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.5
array(2) { ["path"]=> string(12) "/example.com" ["host"]=> string(0) "" } bool(false)

preferences:
243.16 ms | 402 KiB | 342 Q