protected function isValidDomain($hostname)
    {
        return preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $hostname)
            && preg_match("/^.{1,253}$/", $hostname)
            && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $hostname)
            && !preg_match("/^\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}$/", $hostname);
    }
protected function isValidDomain($hostname)
    {
        return preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $hostname)
            && preg_match("/^.{1,253}$/", $hostname)
            && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $hostname)
            && !preg_match("/^\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}$/", $hostname);
    }
protected function isValidDomain ( $ hostname ) { return preg_match ( "/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i" , $ hostname ) && preg_match ( "/^.{1,253}$/" , $ hostname ) && preg_match ( "/^[^\.]{1,63}(\.[^\.]{1,63})*$/" , $ hostname ) && ! preg_match ( "/^\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}$/" , $ hostname ) ; }
Check if the hostname is valid a valid domain name according to RFC 3986 and RFC 1123

@param string $hostname
@return boolean
Check if the hostname is valid a valid domain name according to RFC 3986 and RFC 1123