First a simple example and then one explaining how to catch errors (which should never happen according to the RFC).
<?php
// maybe convert the result to ISO-8859-1 using utf8_decode()
echo idn_to_utf8("xn--tst-qla.de");
// Should never happen but to be sure...
$utf8 = idn_to_utf8("xn--tst-qla.de", $errorcode);
if ($utf8 === false) {
printf("Detected error %d: %s\n", $errorcode, idn_strerror($errorcode));
}
?>
Результатом выполнения данного примера
будет что-то подобное: