Use this php function to get domain name form a URL. A simple function which takes a valid url and returns you a domain name.
function getDomainName($sourceurl) {
if(filter_var($sourceurl, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)===FALSE) {
return false;
}
$url_parts = parse_url($sourceurl);
return $url_parts['scheme'].'://'.$url_parts['host'];
}
function getDomainName($sourceurl) {
if(filter_var($sourceurl, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)===FALSE) {
return false;
}
$url_parts = parse_url($sourceurl);
return $url_parts['scheme'].'://'.$url_parts['host'];
}
No comments:
Post a Comment