src/Comodojo/Cookies/CookieTools.php
public static function checkDomain($domain_name) {

        if ( $domain_name[0] == '.' ) $domain_name = substr($domain_name, 1);

        return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) //valid chars check
                && preg_match("/^.{1,253}$/", $domain_name) //overall length check
                && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name)); //length of each label

    }
public static function checkDomain($domain_name) {

        if ( $domain_name[0] == '.' ) $domain_name = substr($domain_name, 1);

        return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) //valid chars check
                && preg_match("/^.{1,253}$/", $domain_name) //overall length check
                && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name)); //length of each label

    }
public static function checkDomain ( $ domain_name ) { if ( $ domain_name [ 0 ] == '.' ) $ domain_name = substr ( $ domain_name , 1 ) ; return ( preg_match ( "/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i" , $ domain_name ) //valid chars check
 && preg_match ( "/^.{1,253}$/" , $ domain_name ) //overall length check
 && preg_match ( "/^[^\.]{1,63}(\.[^\.]{1,63})*$/" , $ domain_name ) ) ; //length of each label
 }
Check if domain is valid

Main code from: http://stackoverflow.com/questions/1755144/how-to-validate-domain-name-in-php

@param string $domain_name
The domain name to check

@return  bool
Check if domain is valid