Dutch PHP Conference 2025 - Call For Papers

IntlChar::charType

(PHP 7, PHP 8)

IntlChar::charTypeGet the general category value for a code point

Опис

public static IntlChar::charType(int|string $codepoint): ?int

Returns the general category value for the code point.

Параметри

codepoint

Значення кодової точки типу int (наприклад 0x2603 для U+2603 SNOWMAN) або символ UTF-8 типу string (напр. "\u{2603}")

Приклади

Приклад #1 Тестування різних кодових точок

<?php
var_dump
(IntlChar::charType("A") === IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER);
var_dump(IntlChar::charType(".") === IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
var_dump(IntlChar::charType("\t") === IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
var_dump(IntlChar::charType("\u{2603}") === IntlChar::CHAR_CATEGORY_OTHER_SYMBOL);
var_dump(IntlChar::charType("multiple chars") === null);
?>

Поданий вище приклад виведе:

bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top