note 104029 added to filter.examples.validation
| From: | taylanaktepe at yahoo dot com | Date: | Wed, 18 May 2011 13:14:15 +0000 |
| Subject: | note 104029 added to filter.examples.validation | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179846@lists.php.net to get a copy of this message | ||
I used filter_var and preg_match in a email validation function. I try these and get same results
with them. It was useful and simple;
function checks_email($value = '') {
$value = trim($value);
if (function_exists('filter_var')) {
$value = filter_var($value, FILTER_SANITIZE_EMAIL);
if (filter_var($value, FILTER_VALIDATE_EMAIL))
return true;
else
return false;
} else
return preg_match('/^[a-z0-9\,\!\#\\\$\%\&\'\*\+\/\=
\?\^\_\`\{\|\}\~\-]+(\.[a-z0-9\,\!\#\\\$\%\&\'\*\+\/\=\?\^\_
\`\{\|\}\~\-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$/i',
$value);
}
----
Server IP: 69.147.83.197
Probable Submitter: 31.141.87.97
----
Manual Page -- http://www.php.net/manual/en/filter.examples.validation.php
Edit -- https://master.php.net/note/edit/104029
Del: integrated -- https://master.php.net/note/delete/104029/integrated
Del: useless -- https://master.php.net/note/delete/104029/useless
Del: bad code -- https://master.php.net/note/delete/104029/bad+code
Del: spam -- https://master.php.net/note/delete/104029/spam
Del: non-english -- https://master.php.net/note/delete/104029/non-english
Del: in docs -- https://master.php.net/note/delete/104029/in+docs
Del: other reasons-- https://master.php.net/note/delete/104029
Reject -- https://master.php.net/note/reject/104029
Search -- https://master.php.net/manage/user-notes.php