方法一:
~~~
<?php
function br(){
echo '<br />';
}
function is_email($email){
$has_at = strpos($email, "@");
$has_dot = strpos($email, ".");
if($has_at && $has_dot){
return '邮箱地址格式正确!';
}else{
return '邮箱地址格式不正确!';
}
}
echo '邮箱地址 xrccc.com:'.is_email('xrccc.com');
br();
echo '邮箱地址 xrcc_bk@126.com:'.is_email('xrcc_bk@126.com');
?>
~~~
方法二:
~~~
function is_email($email)
{
$i_email = preg_match("/^[a-zA-Z]+@[a-zA-Z1-9]+\.[a-zA-Z]+$/", $email);
if($i_email){
return '正确';
}else{
return '不正确';
}
}
echo is_email('xrccc.com');
br();
echo is_email('xrccbk@126.com');
~~~