Jump to content

Input Validation in the PHP Manual


Glese

Recommended Posts

Validating an email is that easy nowadays? Did I understand right, all I have to do is:

 

filter_var($email, FILTER_VALIDATE_EMAIL);

 

 

Is this accurate, the way how I have understood it?

 

How can I tell, what FILTER_VALIDATE_EMAIL finally is doing or how exactly it is filtering, does documentation state this somewhere?

How can I tell, what FILTER_VALIDATE_EMAIL finally is doing or how exactly it is filtering, does documentation state this somewhere?

 

The internal workings generally aren't documented, and what exactly this email validation accepts as valid would take a lot of describing (though it would be nice to have this).  This email validation simply uses a regular expression. The exact regular expression used has changed over time since FILTER_VALIDATE_EMAIL was introduced, but you can see it in the PHP source code.  Here it is for the upcoming PHP 5.4, http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/ext/filter/logical_filters.c?view=markup#l499

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.