Home  >  Article  >  php教程  >  php中判断是否为合法邮编(固定长度)

php中判断是否为合法邮编(固定长度)

WBOY
WBOYOriginal
2016-06-13 10:03:561033browse

本函数的作 用判断是否为合法邮编(固定长度),方法很简单就是用正则来操作。

 代码如下 复制代码


// 函数名: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;;

}

}

?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn