If you want a PHP script to validate an email address here is a quick and simple PHP regular expression to do it. This script is also case-insensitive, so it will treat all characters as lower case. This script is a simple and  easy way to check the syntax and format of an email address.

The code


<?php

$email "someone@example.com";

if(eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$"$email)) {

  echo "Valid email address.";

}

else {

  echo "Invalid email address.";

}

?>




2 Responses to “Validate an email address using regular expressions”  

  1. 1 Rudra

    Keep up the good work.

  2. 2 SATEESH VP

    good example

Leave a Reply