2

Function not working it's giving me error

Warning: preg_match(): Unknown modifier '_' in /home/u170751922/public_html/include/functions/main.php on line 325

Here is my code :

function verify_valid_email($emailtocheck)
{
       $eregicheck = "^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}\$/i";
       return preg_match($eregicheck, $emailtocheck);
}

1 Answers1

4

You've forgotten delimiters:

$eregicheck = "/^([-!#\$%&'*+.\/0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+\/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}\$/i";

-and, also, note, that / as a delimiter must be escaped in regex itself

Alma Do
  • 37,009
  • 9
  • 76
  • 105