php 邮编正则表达式
<?php
if ($_POST) {
if (funcZip($_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 funcZip($str) //邮编正则表达试
{
return (preg_match("/^[0-9]\d{5}$/", $str)) ? true : false;
}
?>教程地址:http://www.phprm.com/code/dea966cbbf8c41d1bfa2187388beae39.html
欢迎转载!但请带上文章地址^^