3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php var_dump(parse_url('/etc/passwd?param=1&foo=bar&test#id')); var_dump(parse_url('dir/file')); var_dump(parse_url('//example.org/dir/file?param=1&foo=bar&test#id')); var_dump(parse_url('http://example.org/dir/file?param=1&foo=bar&test#id')); var_dump(parse_url('/dir/../file')); var_dump(parse_url('//example.org')); var_dump(parse_url('http://example.org//double'));
Output for 5.4.7 - 7.1.0
array(3) { ["path"]=> string(11) "/etc/passwd" ["query"]=> string(20) "param=1&foo=bar&test" ["fragment"]=> string(2) "id" } array(1) { ["path"]=> string(8) "dir/file" } array(4) { ["host"]=> string(11) "example.org" ["path"]=> string(9) "/dir/file" ["query"]=> string(20) "param=1&foo=bar&test" ["fragment"]=> string(2) "id" } array(5) { ["scheme"]=> string(4) "http" ["host"]=> string(11) "example.org" ["path"]=> string(9) "/dir/file" ["query"]=> string(20) "param=1&foo=bar&test" ["fragment"]=> string(2) "id" } array(1) { ["path"]=> string(12) "/dir/../file" } array(1) { ["host"]=> string(11) "example.org" } array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(11) "example.org" ["path"]=> string(8) "//double" }
Output for 4.3.0 - 5.4.6
array(3) { ["path"]=> string(11) "/etc/passwd" ["query"]=> string(20) "param=1&foo=bar&test" ["fragment"]=> string(2) "id" } array(1) { ["path"]=> string(8) "dir/file" } array(3) { ["path"]=> string(22) "//example.org/dir/file" ["query"]=> string(20) "param=1&foo=bar&test" ["fragment"]=> string(2) "id" } array(5) { ["scheme"]=> string(4) "http" ["host"]=> string(11) "example.org" ["path"]=> string(9) "/dir/file" ["query"]=> string(20) "param=1&foo=bar&test" ["fragment"]=> string(2) "id" } array(1) { ["path"]=> string(12) "/dir/../file" } array(1) { ["path"]=> string(13) "//example.org" } array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(11) "example.org" ["path"]=> string(8) "//double" }