Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 10:03:56
Original
1140 people have browsed it

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

 代码如下 复制代码


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

}

}

?>

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template