1、PHP里的验证模块Ctype 函数
ctype_alnum('abcdef1234'); // This returns TRUE ctype_alnum('£%^&ab2'); // This on the otherhand returns FALSE // check if input is alpha (letters) ctype_alpha('dssfsdf'); // returns TRUE ctype_alpha('12345dssfsdf'); // Returns FALSE // Check if the input is numeric ctype_digit('1234'); // TRUE ctype_digit('1as2d34f'); // FALSE
2、is 系列函数
is_bool() – Finds out whether a variable is a boolean is_null() – Finds whether a variable is NULL is_float() – Finds whether the type of a variable is float is_int() – Find whether the type of a variable is integer is_string() – Find whether the type of a variable is string is_object() – Finds whether a variable is an object is_array() – Finds whether a variable is an arrayctype_alnum — Check for alphanumeric character(s)
检测是否是只包含[A-Za-z0-9] ctype_alpha — Check for alphabetic character(s) 检测是否是只包含[A-Za-z]ctype_cntrl — Check for control character(s)
检查是否是只包含类是“ ”之类的字符控制字符ctype_digit — Check for numeric character(s)
检查时候是只包含数字字符的字符串(0-9)ctype_graph — Check for any printable character(s) except space
检查是否是只包含有可以打印出来的字符(除了空格)的字符串ctype_lower — Check for lowercase character(s)
检查是否所有的字符都是英文字母,并且都是小写的ctype_print — Check for printable character(s)
检查是否是只包含有可以打印出来的字符的字符串ctype_punct — Check for any printable character which is not whitespace or an alphanumeric character
检查是否是只包含非数字/字符/空格的可打印出来的字符ctype_space — Check for whitespace character(s)
检查是否是只包含类是“ ”之类的字符和空格ctype_upper — Check for uppercase character(s)
检查是否所有的字符都是英文字母,并且都是大写的ctype_xdigit — Check for character(s) representing a hexadecimal digit
检查是否是16进制的字符串,只能包括“0123456789abcdef”nl2br();// \n to
addslashes(); stripslashes();//对数据库操作时,转义特殊字符 chop();//除去字符串右边空格 trim();//除去字符串中所有空格 ltrim();//除去字符串左边空格htmlspecialchars();//转换’$’,’”‘,’<’,'>’为相应的html实体
htmlentities();//转换所有html标记为相应的html实体array explode(string separator, string str);//分割字符串
string implode(string separator, array arr);//连接字符串strtoupper(); strtolower();//转换大小写
ucfirst();//只转换第一个字符为大写 ucwords();//转换每个words的第一个字母为大写办事的还有:
PHP Filter 函数