Пример #1
0
 /**
  * Get the domain name from current hostname
  */
 public static function getDomain($tld = true)
 {
     $hostname = self::getHost();
     $domain = preg_replace("/^(.*\\.)?([^.]*\\..*)\$/i", "\$2", $hostname);
     if (Validate::isIp($hostname) || Validate::isIpv6($hostname)) {
         return $hostname;
     }
     if ($tld !== true) {
         return preg_replace("/\\.[a-z]+\$/i", "", $domain);
     }
     return $domain;
 }