parse_url

parse_url

This would have to be one of the most useful functions that I’ve ever stumbled across. It’s called parse_url, and it accepts a string representation of a URL:

array parse_url ( string url)

It returns an associative array containing the various parts of the URL, such as the protocol, host, port, path, query string, etc. This function could come in handy when you require a user to enter a valid URL for something like a competition, feedback form, etc.

The parse_url function is simple enough, and can be used like this:

<?php

$myDomain= parse_url(”http://www.devarticles.com/?param1=blah#bottom”);

echo “Domain: ” . $myDomain[”host”] ;
echo “Query String: ” . $myDomain[”query”] ;
echo “Anchor: ” . $myDomain[”fragment”] ;

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.