E-mail validation in php? [duplicate]

南楼画角 提交于 2019-12-20 05:40:44

问题


Possible Duplicates:
PHP email validation function
Is there a php library for email address validation?

I have a contact form on my site but I need a e-mail validation and I don't know how to do it.


回答1:


$email = "someone@example.com";

if(!filter_var($email, FILTER_VALIDATE_EMAIL))
  {
  echo "E-mail is not valid";
  }
else
  {
  echo "E-mail is valid";
  }

This is probably the simplest method. The example I pasted above is from http://www.w3schools.com/php/filter_validate_email.asp and complete documentation on using filter_var is available at http://us2.php.net/manual/en/function.filter-var.php




回答2:


my old good friend Google have me some interesting links:

http://www.spoono.com/php/tutorials/tutorial.php?id=41

http://www.linuxjournal.com/article/9585

http://www.plus2net.com/php_tutorial/php_email_validation-ajax.php

http://www.devshed.com/c/a/PHP/Email-Address-Verification-with-PHP/1/



来源:https://stackoverflow.com/questions/2235794/e-mail-validation-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!