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函數