How to Solve a Problem With the PHP Function IDN_To_ASCII
If you are using a PHP version below 5.3 you probably will not have the PECL idn or intl extensions installed. So you may run into problems trying to use the idn_to_ascii function. This article will show you how to solve this problem and get the function working properly.
The idn_to_ascii() function converts a domain name in Unicode to its ASCII-compatible form. It returns either the ACE encoded "xn-" string or FALSE if an error occurs. This function is part of the internationalization (or intl) module of PHP. The intl module provides Unicode and Globalization support to PHP.
You may encounter the "Call to undefined Function idn_to_ascii()" error if you try to use this function without the intl extension installed. You should also avoid encoding the input string in utf8 without a BOM or you will run into other errors. This is because most text editors do not handle the utf8 without BOM encoding properly. For example, the string 'casino' will be interpreted as '??????' and the function will fail.
Another way to solve this is to use the idn_to_ascii() method from the ICU library. This method is similar to the idn_to_utf8() method but does not require any PHP PECL extensions. It is a good choice if you want to keep your PHP code small and simple. You can find this method at: https://github.com/jswitch/idn_to_ascii. This is a very simple class which you can download and include into your code to get the function working correctly.