//判断是否是字母和数字或字母数字的组合 if(!ctype_alnum($str)){ echo '只能是字母或数字的组合';exit; }
整理下ctype functions:
1.ctype_alnum(string $text)://检查是否是字母或数字或字母数字的 组合 2.ctype_alpha(string $text):check for alphabetic character(s) //检查字符串是否是字母 3.ctype_cntrl(string $text):check for control character(s) //是否是控制字符如 , , 4.ctype_digit(strint $text):check for numeric character(s) //是否是数字表示的字符 5.ctype_graph(string $text):Check for any printable character(s) except space //检查是否有任何可打印字符,除了空格(补) 6.ctype_lower():check for lowercase character(s)//检查是否是小写字母 7.ctype_upper():check for uppercase character(s)//检查是否是大写字母 8.ctype_space: check for whitespace character(s)//是否是空白字符 9.ctype_xdigit: check for character(s) representing a hexadecimal digit//检查是否是十六进制数字
ctype_digit() 与 is_numeric() 的区别:
$numeric_string='123'; $interger = 123; ctype_digit($numeric_string);//true ctype_digit($interger);//false is_numeric($numeric_string); //true is_numeric($interger); //true
http://www.cnblogs.com/wenzichiqingwa/archive/2012/09/05/2671359.html