How to fix `idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated` error in CodeIgniter

I faced this error while developing a project in CodeIgniter and suddenly form_validation thrown this idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated error.

This error occurs when you using CodeIgniter 3.x version on PHP > 5.4. CodeIgniter was using a deprecated idn_to_ascii() function. This function is deprecated in PHP > 5.4.

I tried to check which validation rule generating this error and then I got valid_email rule was generating this error. This rule was using idn_to_ascii() function which throwing error.

How to Fix

Open the Form_validation.php file in system/libraries/Form_validation.php in your notepad and find valid_email() function. You have to replace existing function code with the following code.

public function valid_email($str)
 if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches))
 $domain = defined('INTL_IDNA_VARIANT_UTS46')
 ? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46)
 : idn_to_ascii($matches[2]);
 $str = $matches[1].'@'.$domain;

 return (bool) filter_var($str, FILTER_VALIDATE_EMAIL);

Save the file and use it.


  1. Thanks for sharing excellent informations.
    Your site is very cool. I’m impressed by the details that you have on this blog.
    It reveals how nicely you perceive this subject. Bookmarked this web page, will come back
    for extra articles. You, my pal, ROCK! I found simply the info I already searched
    all over the place and just couldn’t come across. What a great website.

  2. It’s actually a nice and helpful piece of info. I’m glad that you shared this useful information with us. Please keep us informed like this. Thanks for sharing.

  3. Surely you would not like to have a plumber who charges a king’s ransom but struggles to fix the problem for you.
    You just twist this and untwist that; screw this
    and unscrew that, or cut this and cover that.
    Most residential pipes are unable to withstand harsh commercial
    caustic drain cleaners, ultimately causing further damage.

    Here is my web page trenchless sewer repair Indianapolis.

  4. First of all, should you wish to rework your appearance, then slimming could develop a difference.
    I think the biggest way to network online is via social bookmarking sites.

  5. Publishers notice when an author writes for highly publicized and popular online
    pages. Kim has 392 fans and keeps them well entertained
    and equipped. There are lot of SEO Friendly Directories located on the web.