note 28011 deleted from function.ereg by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Sun, 29 Dec 2002 22:39:58 +0000 |
| Subject: | note 28011 deleted from function.ereg by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-41432@lists.php.net to get a copy of this message | ||
A good example of using ereg is to validate an email given by a user, like so:
function is_valid($email){
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email)){
return 1;
} else {
return 0;
}
}
It is very helpful when you want to make sure you can reach someone through an email form or
whatnot. Here's an example:
if (is_valid("username@email.com")){
echo "valid email.";
} else {
echo "invalid email.";
}