Simple PHP object to check for valid email

Here is a simple code for PHP that will help you check if a given string is a valid e-mail!

function checkEmail($email){
    $regularExpression="/^[a-z]+[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]+\.[a-zA-Z]{2,4}$/";
    if(preg_match($regularExpression, $email))
    {
        return "Valid";
    }

   return  "Not Valid";
}
$isValid = checkEmail("someone@email.com");

Categories