<?
if( $_POST)
{
if( funcEmail( $_POST['url'] ) )
{
echo '有效邮箱地址';
}
else( funcCard( $_POST['url'] ) )
{
exit('请输入正确的邮箱地址');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php 邮箱正则表达式</title>
</head>
<body>
<form id="111cnNet" name="111cnNet" method="post" action="">
<input name="url" type="text" />
<input name="" type="submit" value="提交 "/>
</form>
</body>
</html>
<?
function funcEmail($str)//邮箱正则表达式
{
return (preg_match('/^[_.0-9a-z-A-Z-]+@([0-9a-z][0-9a
-z-]+.)+[a-z]{2,4}$/',$str))?true:false;
}
?>
时间: 2024-12-24 07:34:52