3v4l.org

run code in 300+ PHP versions simultaneously
<?php foreach([ 'scheme://user@host/path', 'scheme://host/path', '/path', 'path', '//host/path', 'x:/path', 'scheme:///path', 'file:///path', 'file:/path', 'file:path', ] as $url) { print "\n: $url\n"; if($url === '--') continue; $path = parse_url($url); if($path === false) { print '"Seriously malformed URL." (q) https://php.net/parse_url' . "\n"; continue; } $ta = []; if(isset($path['scheme'])) $ta = array_merge($ta, [$path['scheme'], ":"]); if(isset($path['host']))// || (isset($path['scheme']) && isset($path['path']))) $ta[] = "//"; if(isset($path['user'])) $ta[] = $path['user']; if(isset($path['pass'])) $ta = array_merge($ta, [":", $path['pass']]); if(isset($path['user'])) $ta[] = "@"; if(isset($path['host'])) $ta[] = $path['host']; if(isset($path['port'])) $ta = array_merge($ta, [":", $path['port']]); if(isset($path['path'])) $ta[] = $path['path']; if(isset($path['query'])) $ta = array_merge($ta, ["?", $path['query']]); if(isset($path['fragment'])) $ta = array_merge($ta, ["#", $path['fragment']]); print implode(" ", $ta) . "\n"; }
Output for 5.4.7 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.15, 8.3.0 - 8.3.2
: scheme://user@host/path scheme : // user @ host /path : scheme://host/path scheme : // host /path : /path /path : path path : //host/path // host /path : x:/path x : /path : scheme:///path "Seriously malformed URL." (q) https://php.net/parse_url : file:///path file : /path : file:/path file : /path : file:path file : path
Output for 5.4.0 - 5.4.6
: scheme://user@host/path scheme : // user @ host /path : scheme://host/path scheme : // host /path : /path /path : path path : //host/path //host/path : x:/path x : /path : scheme:///path "Seriously malformed URL." (q) https://php.net/parse_url : file:///path file : /path : file:/path file : /path : file:path file : path
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/8tMlW on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/8tMlW on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/8tMlW on line 2
Process exited with code 255.

preferences:
178.98 ms | 403 KiB | 360 Q