The "Call to Undefined Function idn_to_ascii()" error in PHP can be confusing. Many people assume this function is part of PHP, and it is, but not always!
It turns out that the idn_to_ascii() function is only available in the internationalization module (or intl module). The int module provides Unicode and Globalization support for PHP. It also provides many functions that are useful for date and time formatting. The idn_to_ascii() function is one of these functions. It is used to convert a Unicode domain name to an IDNA ASCII-compatible format.
Install idn_to_ascii() via Ubuntu
You can install idn_to_ascii() by running the following in your Ubuntu console:
sudo apt-get install php7.2-intl
Note: You may use a different version of PHP, so change the version number from 7.2 to yours. Also, you may need to restart Apache and PHP-FPM if needed:
NOTICE: Not enabling PHP 7.2 FPM by default. NOTICE: To enable PHP 7.2 FPM in Apache2 do: NOTICE: a2enmod proxy_fcgi setenvif NOTICE: a2enconf php7.2-fpm NOTICE: You are seeing this message because you have apache2 package installed.
Install idn_to_ascii() via CPanel
CPanel allows you to select the version of PHP. You can also choose the various PHP modules you want to enable.
Open your CPanel and look for the 'Select PHP Version' menu item.
Next, enable the idn_to_ascii() function by selecting 'intl' from the list.
Remember to click 'save'! :-)
Your idn_to_ascii() function should now be defined!
You may also be interested in
About the Authors
Anto's editorial team loves the cloud as much as you! Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic! Contact Anto Online if you want to contribute.
Support the Cause
Support Anto Online and buy us a coffee. Anything is possible with coffee and code.