PHP Function IDN_TO_UTF8
PHP has a large number of built-in functions, each one performing a certain task. They are used to add more functionality to a script, without the need to write custom code to implement the same task. Functions are executed when the script is called. You can call a function by name, or pass it variables to control its behaviour and return values.
This article describes the php function idn_to_utf8, which converts an IDNA (Domain Name System) domain name into a UTF-8 encoded string. The function will not work if used on a whole URL; it is only valid for the domain part of a URL.
The function takes two arguments: the domain name to convert, and an array of flags and variants to use during conversion. It will only return an error if any of these arguments are not passed. The array contains the keys'result', which is the converted string; 'flags', which specifies if any of the flags are used; 'variant', an int representing a bitset of the error constants IDNA_ERROR_*, and 'idna_info', a map of strings that are valid identifiers for the domain in question.
This function is part of the Symfony Polyfill project, a set of extensions that backports features found in the latest PHP versions and provides compatibility layers for some extensions. More information can be found in the main Polyfill README. The function is available under the MIT license.