Home >php教程 >php手册 >判断数字大小

判断数字大小

WBOY
WBOYOriginal
2016-06-13 11:16:302279browse

 

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

# 判定数字大小,无大小的判定可以用系统带的 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;
}
}


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