3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $url = 'http://www.example.com#fra/gment'; echo $url . "\n"; var_dump(parse_url($url)); $url = 'http://www.example.com?p=1/param'; echo $url . "\n"; var_dump(parse_url($url)); // No host, should return false $url = 'http://#fra/gment'; echo $url . "\n"; var_dump(parse_url($url)); // No host, should return false $url = 'http://?p=1/param'; echo $url . "\n"; var_dump(parse_url($url)); // No host, should return false $url = 'http://youtube.com/?param=http://youtube.com'; echo $url . "\n"; var_dump(parse_url($url));
based on PKG0q
Output for 5.6.28, 7.0.20 - 7.2.0
http://www.example.com#fra/gment array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(15) "www.example.com" ["fragment"]=> string(9) "fra/gment" } http://www.example.com?p=1/param array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(15) "www.example.com" ["query"]=> string(9) "p=1/param" } http://#fra/gment bool(false) http://?p=1/param bool(false) http://youtube.com/?param=http://youtube.com array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(11) "youtube.com" ["path"]=> string(1) "/" ["query"]=> string(24) "param=http://youtube.com" }
Output for 5.3.19 - 5.6.21, 7.0.0 - 7.0.6
http://www.example.com#fra/gment array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(19) "www.example.com#fra" ["path"]=> string(6) "/gment" } http://www.example.com?p=1/param array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(19) "www.example.com?p=1" ["path"]=> string(6) "/param" } http://#fra/gment array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(4) "#fra" ["path"]=> string(6) "/gment" } http://?p=1/param array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(4) "?p=1" ["path"]=> string(6) "/param" } http://youtube.com/?param=http://youtube.com array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(11) "youtube.com" ["path"]=> string(1) "/" ["query"]=> string(24) "param=http://youtube.com" }