php 邮箱正则表达式
<?php if ($_POST) { if (funcEmail($_POST['url'])) { echo '有效邮箱地址'; } else (funcCard($_POST['url'])) { exit('请输入正确的邮箱地址'); } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>php 邮箱正则表达式</title> </head> <body> <form id="phprm" name="phprm" method="post" action=""> <input name="url" type="text" /> <input name="" type="submit" value="提交 "/> </form> </body> </html> <?php function funcEmail($str) //邮箱正则表达式 { return (preg_match('/^[_.0-9a-z-A-Z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$/', $str)) ? true : false; } ?>
本文地址:http://www.phprm.com/code/c9002da4d124e49267f750f8663221a1.html
转载随意,但请附上文章地址:-)