/*
Write a function that when given a URL as a string, parses out just the domain
name and returns it as a string. For example:
* url = "http://github.com/carbonfive/raygun" -> domain name = "github"
* url = "http://www.zombie-bites.com" -> domain name = "zombie-bites"
* url = "https://www.cnet.com" -> domain name = cnet"
*/
const domainName = url => {
let regExp = /http(s)?://|www./gi
return url.replace(regExp, "").split(".")[0]
}
// With love @kouqhar
function fetchLiveDomain($url){
$parts = parse_url($url);
$domain = isset($parts['host']) ? $parts['host'] : '';
if(preg_match('/(?P<domain>[a-z0-9][a-z0-9-]{1,63}.[a-z.]{2,6})$/i', $domain, $regs)){
return $regs['domain'];
}
return FALSE;
}
echo fetchLiveDomain("https://www.pakainfo.com"); // outputs 'pakainfo.com'
echo fetchLiveDomain("http://www.pakainfo.com"); // outputs 'pakainfo.com'
echo fetchLiveDomain("http://mail.pakainfo.co.uk"); // outputs 'pakainfo.co.uk'
<?php
// php get domain name with https.
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$fullurl = "https";
else
$fullurl = "http";
// Now put the default URL characters using PHP.
$fullurl .= "://";
// put the host(domain name, ip) to the URL using PHP.
$fullurl .= $_SERVER['HTTP_HOST'];
// put the requested resource location to the URL using PHP
$fullurl .= $_SERVER['REQUEST_URI'];
// display the fullurl
echo $fullurl;
?>
//https://www.pakainfo.com/
<?php
// Get The Current Page URL with PHP $_SERVER.
$fullurl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ?
"https" : "http") . "://" . $_SERVER['HTTP_HOST'] .
$_SERVER['REQUEST_URI'];
echo $fullurl;
?>