PHP Tutorial : Validate email address – simple way with filter_var() function

While browsing php.net without any scope I discovered a very cute & nice way to replace the usual regular expression email checking thing.

That way is via filter_var() php function which does the things 10 times faster :

<?php
$email = "someone@example.com";

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Invalid email address";
}
?>

One Response to “PHP Tutorial : Validate email address – simple way with filter_var() function”

  1. PHP Tutorial : Validate email address – simple way with filter_var() function | pc-aras Says:

    [...] :: readytousesolutions Share and [...]


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>