Exception: Notice: Use of undefined constant ICONV_IMPL Print

  • magento, magento 2, cpanel, error, iconv, php.ini
  • 1

Exception: Notice: Use of undefined constant ICONV_IMPL

Are you experiencing this error when visiting your Magento 2 website? Let's check and resolve the main cause of this problem. Typically, this is caused by missing "iconv" PHP extension, or lacking iconv configuration inside your php.ini file.

First, log in to your server via SSH and paste in the following:
php -i | grep 'iconv support'

If iconv is enabled and included in your PHP version, you should see "iconv support => enabled" but if you see nothing here, you'll need to check with your server administrator to find out more about your PHP version.
If you have a cPanel server, it might be that you have accidentally unselected the iconv extension in WHM. To check this, log in to WHM, click Software, then EasyApache 4, and look out for the iconv extension against your selected version of PHP.

Once you have iconv support enabled, the next step is to edit your php.ini file to enable iconv features. With cPanel servers, this can be edited by logging into WHM, clicking Software, then MultiPHP INI Editor.

If you have a server without a control panel, enter the following into your SSH terminal:
php -i | grep php.ini
This will show you the location of your php.ini file. You can then use your favourite text editor to edit this file.

Once you have your respective php.ini file open and ready to edit, we need to uncomment (or add) the following iconv entries:

iconv.input_encoding = ISO-8859-1
iconv.internal_encoding = ISO-8859-1
iconv.output_encoding = ISO-8859-1
intl.error_level = 0

Once you have those added, edited or uncommented, it's time to restart Apache or Litespeed or PHP-FPM, however your PHP is configured. Then, a simple refresh of your Magento webpage should resolve the problem!


Was this answer helpful?

« Back