The purpose of this function is to determine whether it is a legal zip code (fixed length). The method is very simple, just use regular expressions to operate.
The code is as follows
代码如下 |
复制代码 |
< ?php
// 函数名:CheckPost($C_post)
// 作 用:判断是否为合法邮编(固定长度)
// 参 数:$C_post(待check的邮政编码)
// 返回值:布尔值
// 备 注:无
//-----------------------------------------------------------------------------------
function CheckPost($C_post)
{
$C_post=trim($C_post);
if (strlen($C_post) == 6)
{
if(!ereg("^[+]?[_0-9]*$",$C_post))
{
return true;;
}else
{
return false;
}
}else
{
return false;;
}
}
?>
|
|
Copy code |
|
< ?php
// Function name: CheckPost($C_post)
// Function: Determine whether it is a legal zip code (fixed length)
// Parameter: $C_post (postal code to be checked)
//Return value: Boolean value
// Remarks: None
//--------------------------------------------- ----------------------------------------
function CheckPost($C_post){<🎜>
<🎜>$C_post=trim($C_post);<🎜>
<🎜>if (strlen($C_post) == 6)<🎜>
<🎜>{<🎜>
<🎜>if(!ereg("^[+]?[_0-9]*$",$C_post))<🎜>
<🎜>{<🎜>
<🎜>return true;;<🎜>
<🎜>}else<🎜>
<🎜>{<🎜>
<🎜>return false;<🎜>
<🎜>}<🎜>
<🎜>}else<🎜>
<🎜>{<🎜>
<🎜>return false;;<🎜>
<🎜>}<🎜>
<🎜>}<🎜>
<🎜>?>
http://www.bkjia.com/PHPjc/631297.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631297.htmlTechArticleThe function of this function is to determine whether it is a legal zip code (fixed length). The method is very simple, just use regular expressions to operate. The code is as follows Copy code ?php // Function name: CheckPost($C_post) // Function...