What's up with "PHP Unknown: INTL_IDNA_VARIANT_2003 is deprecated"?

in Development


Here's how the error may look like:

PHP Unknown: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated

PHP Unknown: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

The cause is the 2003 version got deprecated and you're supposed to be using UTS46. Most likely though, you were today years old when you first learned about these. PHP is picking one by default, and until 7.3 this worked fine. In 7.3 however, it defaults to the deprecated 2003 standard, and the worst thing is it does that on purpose (yeah), and there doesn't seem to be a way to at least set the new one as default.

The workaround is to explicitly use the new INTL_IDNA_VARIANT_UTS46 everywhere you call idn_to_*():

idn_to_utf8($string, 0, INTL_IDNA_VARIANT_UTS46)

If you call them a lot, it's going to be an unnecessary burden.

The solution is to upgrade to 7.4

#php