I have a PHP function to validate e-mail fields. In my PHP file, I receive below error:
Warning: preg_match(): Unknown modifier '_' in C:\xampp\htdocs\validator.inc.php on line 28
My PHP file is:
<?php
define("EMAIL_MASK", "^[-!#$%&'*+/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z{|}~])*@[a-zA-Z](-?[a-zA-Z0-9])*(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$");
(...)
function isEmailValid($email)
{
return !empty($email) && preg_match(EMAIL_MASK, $email); <---- This is the line raising the error
}
(...)
?>
What am I doing wrong?