Return to Snippet

Revision: 2211
at January 17, 2007 09:20 by koncept


Updated Code
<?php
/**
 * This function validates an email address, returning an integer
 * depending on whether or not the email address provided is valid.
 * A positive match will yield a result of 1, while a negative match 
 * will yield a result of 0. FALSE will be returned if an error occurred.
 * 
 * @param string $email The email address to validate.
 * @return integer The result of the validation.
 */
function isValidEmail( $email = null )
{
	return preg_match( "/^
	[\d\w\/+!=#|$?%{^&}*`'~-]
	[\d\w\/\.+!=#|$?%{^&}*`'~-]*@
	[A-Z0-9]
	[A-Z0-9.-]{1,61}
	[A-Z0-9]\.
	[A-Z]{2,6}$/ix", $email );
}
?>

Revision: 2210
at January 16, 2007 18:43 by koncept


Updated Code
<?php
/**
 * This function validates an email address, returning boolean TRUE or FALSE
 * depending on whether or not the email address provided is valid.
 * 
 * @param string $email The email address to validate.
 * @return integer The result of validation (match=1, no match=0, FALSE if error).
 */
function isValidEmail( $email = null )
{
	return preg_match( "/^
	[\d\w\/+!=#|$?%{^&}*`'~-]
	[\d\w\/\.+!=#|$?%{^&}*`'~-]*@
	[A-Z0-9]
	[A-Z0-9.-]{1,61}
	[A-Z0-9]\.
	[A-Z]{2,6}$/ix", $email );
}
?>

Revision: 2209
at January 16, 2007 18:42 by koncept


Updated Code
<?php
/**
 * This function validates an email address, returning boolean TRUE or FALSE
 * depending on whether or not the email address provided is valid.
 * 
 * @param string $email The email address to validate.
 * @return boolean The result of validation.
 */
function isValidEmail( $email = null )
{
	return preg_match( "/^
	[\d\w\/+!=#|$?%{^&}*`'~-]
	[\d\w\/\.+!=#|$?%{^&}*`'~-]*@
	[A-Z0-9]
	[A-Z0-9.-]{1,61}
	[A-Z0-9]\.
	[A-Z]{2,6}$/ix", $email );
}
?>

Revision: 2208
at January 16, 2007 18:36 by koncept


Initial Code
<?php
/**
 * This function validates an email address, returning boolean TRUE or FALSE
 * depending on whether or not the email address provided is valid.
 * 
 * @param string The email address to validate.
 * @return boolean The result of validation.
 */
function isValidEmail( $email = null )
{
	return preg_match( "/^
	[\d\w\/+!=#|$?%{^&}*`'~-]
	[\d\w\/\.+!=#|$?%{^&}*`'~-]*@
	[A-Z0-9]
	[A-Z0-9.-]{1,61}
	[A-Z0-9]\.
	[A-Z]{2,6}$/ix", $email );
}
?>

Initial URL


Initial Description


Initial Title
PHP Email Validation

Initial Tags
email, php, function, validation

Initial Language
PHP