Home  >  Article  >  Backend Development  >  A small function to detect whether it is a valid email address

A small function to detect whether it is a valid email address

WBOY
WBOYOriginal
2016-07-25 09:02:501373browse
  1. /*
  2. // Function name: CheckEmailAddr($C_mailaddr)
  3. // Function: Determine whether it is a valid email address
  4. // Parameter: $C_mailaddr (email address to be detected)
  5. // Return value: Boolean value
  6. // Remarks: None
  7. */
  8. function CheckEmailAddr($C_mailaddr)
  9. {
  10. if (!eregi(“^[_a-z0-9-]+(.[_a-z0-9-] +)*@[a-z0-9-]+(.[a-z0-9-]+)*$”,
  11. $C_mailaddr))
  12. //(!ereg(“^[_a-zA-Z0- 9-]+(.[_a-zA-Z0-9-]+)*@[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$”,
  13. $c_mailaddr))
  14. {
  15. return false;
  16. }
  17. return true;
  18. }
  19. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn