Hello.

It was necessary to make a functional transfer of the domain to Christmas trees-with-delivery. RF in such xn ----- 8kciivmbgc2bd6adp4u.xn - p1ai

How to do this in PHP?

2 answers 2

as advised by @Etki, you should use the idn_to_ascii function (inverse transform: idn_to_utf8 ).

it is likely that we are talking about a server running the gnu / linux operating system. there you need to install the php5-intl package ( php-idn , etc.) containing the implementation of these functions.

example:

 $ php -r "echo idn_to_ascii('домен.рф');" xn--d1acufc.xn--p1ai $ php -r "echo idn_to_utf8('xn--d1acufc.xn--p1ai');" домен.рф 

    Most often advised to use third-party classes. For example, there is such an example .

    • It is even better to use the library that is loaded via composer, as in my comments. - etki