Saturday, May 15, 2010

How to Extract Domain name from URL ?

Here is a simple example describe below.

“parse_url” function can be used to parse the URL.

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.example.com and path and the query.

eg. consider this url – “http://www.example.com/page.php?id=1”

In “http://www.example.com/page.php?id=1” this url if you execute parse_url function then it will show the following result.

Scheme - http
url - www.example.com
path - /page.php
query - id=1

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off