note 28011 added to function.ereg

From: Date: Sun, 29 Dec 2002 20:26:08 +0000
Subject: note 28011 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-41427@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."; } -- http://www.php.net/manual/en/function.ereg.php http://master.php.net/manage/user-notes.php?action=edit+28011 http://master.php.net/manage/user-notes.php?action=delete+28011 http://master.php.net/manage/user-notes.php?action=reject+28011

« previous php.notes (#41427) next »