PHP FILTER_VALIDATE_EMAIL 过滤器 详解
php基础 2022-06-06 17:28:44小码哥的IT人生shichen
PHP FILTER_VALIDATE_EMAIL 过滤器
定义和用法
FILTER_VALIDATE_EMAIL 过滤器把值作为电子邮件地址来验证。
- Name: "validate_email"
- ID-number: 274
例子
<?php
$email = "someone@exa mple.com";
if(!filter_var($email, FILTER_VALIDATE_EMAIL
))
{
echo "E-mail is not valid";
}
else
{
echo "E-mail is valid";
}
?>
输出:
E-mail is not valid