Idn_to_ascii () at 5.2.17

PHP 5.3 has a very convenient idn_to_ascii () function, but I am running 5.2.17 and I cannot change it. How can I encode Unicode domain names in ascii then?

+4
source share
2 answers

Peter's answer gives you the official IDN features in PHP 5.2, and if possible, this is the best answer.

However, some users will not be able to install the PECL library in their PHP system, so they will need a conversion library written in plain PHP that they can simply include in their own code.

Fortunately, there is a solution: http://phlymail.com/en/downloads/idna/

This is a PHP class that allows you to encode and decode between unicode and punycode. Very easy to use and does not require any installation (other than downloading and incorporating into your own PHP code).

Obviously, you do not need this if you are using PHP 5.3 or better, or if you can install the PECL library in PHP 5.2, but if you cannot do this, this is a good alternative.

+5
source

Quote:

This extension can be installed using bundled with PHP version 5.3.0, or as a PECL extension for PHP 5.2.0. In other words, there are two ways to install an internal extension.

Instructions here

General installation instructions

pecl install intl pecl install idn 

Then add the extensions to your php.ini files or the corresponding configuration files.

+4
source

Source: https://habr.com/ru/post/1344923/


All Articles