La función IntlChar::charType() es una función incorporada en PHP que se usa para obtener el valor de categoría general para un punto de código. Esta función devuelve el valor de categoría general para el punto de código.
Sintaxis:
int IntlChar::charType ( $codepoint )
Parámetros: Esta función acepta un solo parámetro $codepoint que es obligatorio. El valor de $codepoint es un carácter o valor entero, que se codifica como una string UTF-8 .
Valor devuelto: esta función devuelve el contenido de la categoría general que se enumeran a continuación:
- 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
Los siguientes programas ilustran la función IntlChar::charType() en PHP:
Programa 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); ?>
Producción:
bool(true) bool(true) bool(true) bool(true) bool(false) bool(true)
Programa 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")); ?>
Producción:
int(1) int(23) int(15) int(27) NULL int(15)
Artículos relacionados:
- PHP | Función IntlChar::charDigitValue()
- PHP | Función IntlChar isMirrored()
- PHP | Función IntlChar::isspace()
Referencia: http://php.net/manual/en/intlchar.chartype.php