3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * Parse an address spec string into an array * * @param $address * @return array * @throws \LogicException */ function parseAddress($address) { if ((!($parts = parse_url($address)) && !($parts = parse_url(preg_replace('#^([^:]+:/)//#', '$1', $address)))) || !isset($parts['scheme']) ) { throw new LogicException('Invalid address spec: ' . $address); } $parts['scheme'] = strtolower($parts['scheme']); return $parts; } var_dump(parseAddress('unix:///foo/bar.sock'));
Output for 5.3.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { ["scheme"]=> string(4) "unix" ["path"]=> string(13) "/foo/bar.sock" }
Output for 5.2.0 - 5.3.2
Warning: parse_url(unix:///foo/bar.sock): Unable to parse URL in /in/Rj3XS on line 12 array(2) { ["scheme"]=> string(4) "unix" ["path"]=> string(13) "/foo/bar.sock" }
Output for 5.0.0 - 5.1.6
Warning: parse_url(unix:///foo/bar.sock): Unable to parse url in /in/Rj3XS on line 12 array(2) { ["scheme"]=> string(4) "unix" ["path"]=> string(13) "/foo/bar.sock" }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/Rj3XS on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_NEW in /in/Rj3XS on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Rj3XS on line 15
Process exited with code 255.