is_numeric:检测是否为数字字符串,可为负数和小数
ctype_digit:检测字符串中的字符是否都是数字,负数和小数会检测不通过
注意,参数一定要是字符串,如果不是字符串,则会返回0/FASLE
拓展(ctype函数):
http://www.php.net/manual/zh/ref.ctype.php
ctype_alnum — 做字母和数字字符检测
ctype_alpha — 做纯字符检测
ctype_cntrl — 做控制字符检测
ctype_digit — 做纯数字检测
ctype_graph — 做可打印字符串检测,空格除外
ctype_lower — 做小写字符检测
ctype_print — 做可打印字符检测
ctype_punct — 检测可打印的字符是不是不包含空白、数字和字母
ctype_space — 做空白字符检测
ctype_upper — 做大写字母检测
ctype_xdigit — 检测字符串是否只包含十六进制字符