PHP 5.2 Validate An Email Address With the Filter_var() Function

October 21, 2011 | By Duchateaux.

From Version 5.2 PHP has Introduced a new Validating Tool: the filter_var() function.
Here is shown How to easily Validate an Email Address in a PHP Form with this function.
The filter_var() function Serve to Filter Variables Content using a given form of Filter. The Second Argument taken by the function is Right a Constant indicating which kind of Filtering the function need to Execute. For a List of Filters look Here.
In our case the Filter Constant for an Email validation is: FILTER_VALIDATE_EMAIL.
Here is an example of Email Validation:


This will Return True if the Submitted Email is well Shaped otherwise it will Return False.

QuickChic Theme • Powered by WordPress