PHP Code Snippet - Validate Email Address

PHP Code Snippet - Validate Email Address

PHP Code Snippet - Validate Email Address

PHP code snippet to validate given email address. IsValidEmail function validate email address. Function return TRUE if valid email address found, if not function will return FALSE.

Bookmark:

PHP Code Snippet - Validate Email Address

This PHP code snippet validate given email address. This function uses regular expression to match string pattern to validate email address.

function IsValidEmail($email)
{
	return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $email);
}


PHP Keywords Used:

  • preg_match

Code Snippet Information:

  • Applies To: PHP, Email Validation, Regular Expression
  • Programming Language : PHP

External Resources:

Leave a comment