|
|
parse_url - get the domain name from url - PHP
|
Views : 418
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
parse_url - Parse a URL and return its components.
If we want the domain name or protocol or arguments from the url, we can just simply use parse url function in php.
Parse_url takes url as argument and returns
* scheme - e.g. http
* host
* port
* user
* pass
* path
* query - after the question mark ?
* fragment - after the hashmark #
Example Code:
$url = 'http://username:password@hostname/path?arg=value#anchor';
print_r(parse_url($url));
?>
The above example will output:
Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => password
[path] => /path
[query] => arg=value
[fragment] => anchor
)
|
|
By rajesh, On - 2010-01-02 |
|
|
|