parse_url is a built in php function which can be used to parse url and get the type of request like whether its http or https or ftp, gives the domain name like www.google.com and path and the query.

below is the sample code

< ?php
$url = "http://www.mistonline.in/index.php?php=4";
$parts = parse_url($url);
print_r($parts);
echo "
scheme - $parts&#91;scheme&#93;";
echo "
url - $parts&#91;host&#93;";
echo "
path - $parts&#91;path&#93;";
echo "
query - $parts&#91;query&#93;";
?>

OutPut

scheme -> http
url -> www.mistonline.in
path -> /index.php
query -> php=4

Leave a Reply

Your email address will not be published. Required fields are marked *