8
1
2008
0

[转][PHP]一个比is_numeric更适合id判断的方法

is_numeric能判定一个变量是否为数字或数字字符串,但是它的判定范围太宽了。整数、小数、指数表示以及16进制数值都会通过判断。
平时判定id的时候,用它就有点不合适。今天发现一个新的判定函数:ctype_digit,它可以只判定整数,这样就比is_numeric好一些。

其他还有ctype_xdigit判定16进制整数,ctype_alpha判定字母等等函数。
参考PHP的ctype函数库

转至:桄欣  发表于2008年07月 23日 Wednesday 19:01 在 编辑部

Category: PHP | Tags: php | Read Count: 2187

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com