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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。