Home > php教程 > php手册 > php通用检测函数集(3)

php通用检测函数集(3)

WBOY
Release: 2016-06-13 10:20:32
Original
861 people have browsed it

// 函数名:CheckTelephone($C_telephone)
// 作 用:判断是否为合法电话号码
// 参 数:$C_telephone(待检测的电话号码)
// 返回值:布尔值
// 备 注:无
//-----------------------------------------------------------------------------------
-------
function CheckTelephone($C_telephone)
{
if (!ereg("^[+]?[0-9]+([xX-][0-9]+)*$", $C_telephone)) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
-------
// 函数名:CheckValueBetween($N_var, $N_val1, $N_val2)
// 作 用:判断是否是某一范围内的合法值
// 参 数:$N_var 待检测的值
// $N_var1 待检测值的上限
// $N_var2 待检测值的下限
// 返回值:布尔值
// 备 注:无
//-----------------------------------------------------------------------------------
-------
function CheckValueBetween($N_var, $N_val1, $N_val2)
{
if ($N_var $N_var2)
{
return false;
}
return true;

}
//-----------------------------------------------------------------------------------
-------


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