CakeFest 2024: The Official CakePHP Conference

IntlChar::charType

(PHP 7, PHP 8)

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

Beschreibung

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

Returns the general category value for the code point.

Parameter-Liste

codepoint

Ein Wert vom Typ int, der einen Codepoint darstellt (z. B. 0x2603 für U+2603 SNOWMAN) oder ein als UTF-8-String kodiertes Zeichen (z. B. "\u{2603}")

Beispiele

Beispiel #1 Testen unterschiedlicher Codepoints

<?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);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

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