PHP Email Validator
Validation is an important factor to develop a reliable aplication in any platform. In this article, we will show you how to validate email address using PHP in the most efficient and accurate way. This email validator is designed to support the complexity of valid email format.
Source Code
[php]<?
//By : Isusx Programming Corner
//URL : http://isusx.com
//Create an email validator function
function is_valid_email($email){
//Divide email sections
$section = split(’@', $email);
//Valid email only contains 2 part: username and domain name
if(count($section) != 2)
return false;
//trimming email sections
$username = trim($section[0]);
$domain = trim($section[1]);
//Both sections must not be an empty string
if($username == ”) return false;
if($domain == ”) return false;
//Validate domain
if(function_exists(’checkdnsrr’)){
if(@checkdnsrr($domain,’MX’))
return true;
else
return false;
}else
return true;
}
//Using the function
if(is_valid_email(’codecentremail@gmail.com’))
echo ‘Valid Email’;
else
echo ‘Invalid Email’;
?>[/php]
Copyright Note
This script is free to use and can be modified as your wish.
Related Links
About Email Address
PHP
What is a Valid Email Address?
PHP:Checkdnsrr function manual




