ctype函数
Ctype功能 (Ctype functions)
PHP provides some of the built-in functions, which are used to verify the characters in the string i.e. to check whether a string contains the characters of specific types.
PHP提供了一些内置函数,这些函数用于验证字符串中的字符,即检查字符串是否包含特定类型的字符。
PHP中的Ctype函数列表 (List of the Ctype functions in PHP)
Here, is the list of the PHP Ctype functions...
这是PHP Ctype函数的列表...
ctype_alnum() - Checks whether given string contains all alphabets or numbers.
ctype_alnum() -检查给定的字符串是否包含所有字母或数字。
ctype_alpha() - Checks whether given string contains all alphabets.
ctype_alpha() -检查给定的字符串是否包含所有字母。
ctype_digit() - Checks whether given string contains all digits.
ctype_digit() -检查给定的字符串是否包含所有数字。
ctype_space() - Checks whether given string contains spaces (whitespaces, tab, new line etc).
ctype_space() -检查给定的字符串是否包含空格(空格,制表符,换行等)。
ctype_lower() - Checks whether given string contains all lowercase characters.
ctype_lower() -检查给定的字符串是否包含所有小写字符。
ctype_upper() - Checks whether given string contains all uppercase characters.
ctype_upper() -检查给定的字符串是否包含所有大写字符。
ctype_punct() - Checks whether given string contains all punctuation characters.
ctype_punct() -检查给定的字符串是否包含所有标点符号。
ctype_xdigit() - Checks whether given string contains all hexadecimal digits.
ctype_xdigit() -检查给定的字符串是否包含所有十六进制数字。
ctype_print() - Checks whether given string contains all printable characters.
ctype_print() -检查给定的字符串是否包含所有可打印字符。
ctype_graph() - Checks whether given string contains all printable characters expect space.
ctype_graph() -检查给定的字符串是否包含所有可打印字符的期望空间。
ctype_cntrl() - Checks whether given string contains all control characters.
ctype_cntrl() -检查给定的字符串是否包含所有控制字符。
PHP Ctype函数示例 (PHP Ctype functions Example)
<?php
echo (ctype_alnum("Hello123")."\n");
echo (ctype_alpha("Helloworld")."\n");
echo (ctype_digit("01234")."\n");
echo (ctype_space("\r\n \t")."\n");
echo (ctype_lower("helloworld")."\n");
echo (ctype_upper("HELLOWORLD")."\n");
echo (ctype_punct("[email protected]#~*&(){}")."\n");
echo (ctype_xdigit("aaff01290")."\n");
echo (ctype_print("Hello world!")."\n");
echo (ctype_graph("[email protected]#")."\n");
echo (ctype_cntrl("\x00\x1F\x7F\r\n")."\n");
?>
Output
输出量
1
1
1
1
1
1
1
1
1
1
1
翻译自: https://www.includehelp.com/php/ctype-character-type-functions.aspx
ctype函数