code3 email validator


SUBMITTED BY: phpsnippets

DATE: Oct. 24, 2015, 10:25 a.m.

FORMAT: Text only

SIZE: 619 Bytes

HITS: 1191

  1. <?php
  2. $email = "email.com";
  3. $email = preg_match("/[a-zA-Z@_-]/", $email);
  4. try
  5. {
  6. if (!$email)
  7. {
  8. throw new Exception("Email is not valid!");
  9. } else
  10. {
  11. return 1;
  12. }
  13. }
  14. catch (exception $e)
  15. {
  16. echo "Error Message: <font color='red'>" . $e->getMessage() . "</font><br />";
  17. echo "The error is on line: <font color='red'>" . $e->getLine() .
  18. "</font><br />";
  19. echo "The file the error is in: <font color='red'>" . $e->getFile() .
  20. "</font><br />";
  21. }
  22. ?>

comments powered by Disqus