How to validate an e-mail address
This is my first tutorial for PHP ![]()
I wrote it because at almost any project this is a “must have” function.
The function is very very simple, it receive as a parameter an e-mail address and it returns the result of the validation (true if the address is valid or false if it isn’t, simple enough
?).
So … how is this done? … using the EREGI PHP function (look at the end of the tutorial for links) which is a regular expression matcher. After about 35 minutes (I didn’t knew anything about the Regular Expression Syntax) I managed to get a working code for this.
(If you want to copy it use the (Show Plain Code link))
-
function CheckEmail($email)
-
{
-
return false;
-
else
-
return true;
-
}
How to use it? Just like a normal PHP function ….
I hope this will help someone, until the next tutorial .. take care
Bibliography :
- http://php.net/eregi – The eregi function documentation + examples
- http://weblogtoolscollection.com/regex/regex.php – PHP Regular Expressions Tutorial