Thursday, August 17, 2017 09:35 am EDT

Validation

Bri's picture

PHP Email Address Validation

Email address validation is a very common thing and it's pretty easy in php 5.2 or greater. You no longer need to use a regular expression. You can use this simple script below, making use of the filter_var function.


$email = 'mail@example.com';
$validation = filter_var($email, FILTER_VALIDATE_EMAIL);

if($validation)
$output = 'proper email address';
else
$output = 'wrong email address';

echo $output;

Syndicate content