Thursday, August 5, 2010

PHP isEmail Function


Code to validate email in PHP using Preg Match.
This will cover emails of format:
asdfasdf@asdfasdf.com

function isEmail($email)
{
      if(preg_match("~([a-zA-Z0-9!#$%&'*+-/=?^_`{|}~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~",$email)) 
        return true;
   else
        return false;
}

No comments:

Post a Comment

Developer Instincts