PHP中的IntlChar charType()函数

IntlCharcharType()函数用于获取输入值的常规类别值。

语法

int IntlChar::charType (val)

参数

  • val-编码为UTF-8字符串的整数或字符。

返回

IntlCharcharType()函数返回以下常规类别内容-

  • 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
   var_dump(IntlChar::charType("n") === IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
   echo "<br>";
   var_dump(IntlChar::charType("jkl") === IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
   echo "<br>";
   var_dump(IntlChar::charType("r") === IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
   echo "<br>";
   var_dump(IntlChar::charType("Z") === IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER);
   echo "<br>";
   var_dump(IntlChar::charType(".") === IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
   echo "<br>";
?>

输出结果

以下是输出-

bool(false)
bool(false)
bool(false)
bool(true)
bool(true)