Check if a domain name is IDN with PHP

In some cases you may need to check if a domain name is IDN (Internationalized domain name) or not.

This function can do it for you (from PHP 5.3+):

//Check if a domain name is IDN or not.
//Return true of the $name is IDN or false of not.
public function is_idn($name)
{
    if(idn_to_utf8($name) != $name)
        return true;

    return false;
}

Then you can call the function ‘is_idn’ as above:

is_idn('xn--5dbhaeldc2j.com');