Home  >  Article  >  Backend Development  >  判断数字大小_PHP教程

判断数字大小_PHP教程

WBOY
WBOYOriginal
2016-07-20 11:00:121972browse

 

判定数字的大小是否在某个范围内,假如仅仅是判定是否为数字无需使用。

# 判定数字大小,无大小的判定可以用系统带的 is_numeric($str)
#----------------------------------------------------------
Function isNumber ($fNum, $fMin="", $fMax="") {
if ( eregi("^[0-9] $", $fNum) ) {
if ( "" == $fMax && "" == $fMin ) {
Return True;
} elseif ( "" == $fMin && $fNum Return True;
} elseif ( "" == $fMax && $fNum >= $fMin ) {
Return True;
} elseif ( $fNum >= $fMin && $fNum Return True;
} else {
Return False;
}
} else {
Return False;
}
}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445546.htmlTechArticle判定数字的大小是否在某个范围内,假如仅仅是判定是否为数字无需使用。 # 判定数字大小,无大小的判定可以用系统带的 is_numeric($str)...
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