IntlChar::charType()函數是PHP中的內置函數,用於獲取代碼點的常規類別值。此函數返回代碼點的常規類別值。
用法:
int IntlChar::charType ( $codepoint )
參數:該函數接受單個參數$codepoint,該參數是必需的。 $codepoint值是整數值或字符,被編碼為UTF-8字符串。
返回值:此函數返回以下列出的常規類別內容:
- IntlChar::CHAR_CATEGORY_UNASSIGNED
- IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES
- IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER
- IntlChar::CHAR_CATEGORY_LOWERCASE_LETTER
- IntlChar::CHAR_CATEGORY_TITLECASE_LETTER
- IntlChar::CHAR_CATEGORY_MODIFIER_LETTER
- IntlChar::CHAR_CATEGORY_OTHER_LETTER
- IntlChar::CHAR_CATEGORY_NON_SPACING_MARK
- IntlChar::CHAR_CATEGORY_ENCLOSING_MARK
- IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK
- IntlChar::CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER
- IntlChar::CHAR_CATEGORY_LETTER_NUMBER
- IntlChar::CHAR_CATEGORY_OTHER_NUMBER
- IntlChar::CHAR_CATEGORY_SPACE_SEPARATOR
- IntlChar::CHAR_CATEGORY_LINE_SEPARATOR
- IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR
- IntlChar::CHAR_CATEGORY_CONTROL_CHAR
- IntlChar::CHAR_CATEGORY_FORMAT_CHAR
- IntlChar::CHAR_CATEGORY_PRIVATE_USE_CHAR
- IntlChar::CHAR_CATEGORY_SURROGATE
- IntlChar::CHAR_CATEGORY_DASH_PUNCTUATION
- IntlChar::CHAR_CATEGORY_START_PUNCTUATION
- IntlChar::CHAR_CATEGORY_END_PUNCTUATION
- IntlChar::CHAR_CATEGORY_CONNECTOR_PUNCTUATION
- IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION
- IntlChar::CHAR_CATEGORY_MATH_SYMBOL
- IntlChar::CHAR_CATEGORY_CURRENCY_SYMBOL
- IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL
- IntlChar::CHAR_CATEGORY_OTHER_SYMBOL
- IntlChar::CHAR_CATEGORY_INITIAL_PUNCTUATION
- IntlChar::CHAR_CATEGORY_FINAL_PUNCTUATION
- IntlChar::CHAR_CATEGORY_CHAR_CATEGORY_COUNT
以下示例程序旨在說明PHP中的IntlChar::charType()函數:
程序1:
<?php
// PHP code to illustrate IntlChar::charType()
// function
// Input data is character type
var_dump(IntlChar::charType("A") ===
IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER);
// Input data is character type
var_dump(IntlChar::charType(".") ===
IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
// Input data is character type
var_dump(IntlChar::charType("\t") ===
IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
// Input data is unicode character
var_dump(IntlChar::charType("\u{2603}") ===
IntlChar::CHAR_CATEGORY_OTHER_SYMBOL);
// Input data is string type
var_dump(IntlChar::charType("ABC") ===
IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
// Input data is character type
var_dump(IntlChar::charType("\n") ===
IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
?>
輸出:
bool(true) bool(true) bool(true) bool(true) bool(false) bool(true)
程序2:
<?php
// PHP code to illustrate IntlChar::charType()
// function
// Input data is character type
var_dump(IntlChar::charType("A"));
// Input data is character type
var_dump(IntlChar::charType("."));
// Input data is character type
var_dump(IntlChar::charType("\t"));
// Input data is unicode character
var_dump(IntlChar::charType("\u{2603}"));
// Input data is string type
var_dump(IntlChar::charType("ABC"));
// Input data is character type
var_dump(IntlChar::charType("\n"));
?>
輸出:
int(1) int(23) int(15) int(27) NULL int(15)
相關文章:
參考: http://php.net/manual/en/intlchar.chartype.php
相關用法
- PHP IntlChar::chr()用法及代碼示例
- PHP IntlChar::ord()用法及代碼示例
- PHP IntlChar::isspace()用法及代碼示例
- PHP IntlChar::ispunct()用法及代碼示例
- PHP IntlChar::isWhitespace()用法及代碼示例
- PHP IntlChar::isUUppercase()用法及代碼示例
- PHP IntlChar hasBinaryProperty()用法及代碼示例
- PHP IntlChar::isalnum()用法及代碼示例
- PHP IntlChar::isbase()用法及代碼示例
- PHP IntlChar::islower()用法及代碼示例
- PHP IntlChar::isxdigit()用法及代碼示例
- PHP IntlChar::isprint()用法及代碼示例
- PHP IntlChar::isUAlphabetic()用法及代碼示例
- PHP IntlChar::isULowercase()用法及代碼示例
- PHP IntlChar::isISOControl()用法及代碼示例
注:本文由純淨天空篩選整理自Mahadev99大神的英文原創作品 PHP | IntlChar charType() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。