php filter_var email error

i use he filter_var php function to validate email address when a user sign up to my site

so i use this code form the post:

$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);

then later i do:

if(!$email) {
  // return to the form 
else {
  // send registration info

now when i var_dump($email)


string(23) "user."name""

i would like to know why this not return false, i think the double quotes are not acceptable why PHP say it's valid?


It is a valid email address :

A quoted string may exist as a dot separated entity within the local-part or it may exist when the outermost quotes are the outermost chars of the local-part (e.g. abc."defghi" or "abcdefghixyz" are allowed. abc"defghi" is not; neither is abc\"def\"

I had the same problem (see Dalmas on why it's valid) and here's how I fixed it:

filter_var($email, FILTER_SANITIZE_EMAIL);


$email = 'user."name"';
$email = filter_var($email, FILTER_SANITIZE_EMAIL);

will output:

string(21) ""

Then you can validate the email using your validation.

you can get more information on the php site

Need Your Help

Using typekit in wkhtmltoimage / imgkit

ruby-on-rails-3.2 wkhtmltopdf wkhtmltoimage imgkit

I am on Rails 3.2.9. Is it possible for me to use typekit (or goggle fonts) for rendering the images? I used the following code, but the images are not rendering the right fonts. I suspected the p...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.