Web Development Knowledge Base
| |
Sections :
RSS Feed You too, please publish your useful code snippets in any programming language : write an article ! Plateforme d'envoi de gros fichiers en ligne Dépannage site web Blog infogérance Hébergement e-mail |
Olivier Ligny - - 21/08/2012 - vue 29409 fois
Check email address syntax with PHP regexIf you need to save and use email addresses that you got from user input, you need to check these addresses are valid and safe to use. Here is a simple regex code that detects if the emails looks valid or not : function isValidEmail($email) { return @eregi("^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,6})$", $email); } Example usage :
echo "Your email is : ".(isValidEmail("john@smith.com") ? "valid" : "incorrect");
|
Nos partenaires : iPhone 8 Cases & Protection |