Dutch PHP Conference 2025 - Call For Papers

IntlChar::ord

(PHP 7, PHP 8)

IntlChar::ordReturn Unicode code point value of character

Опис

public static IntlChar::ord(int|string $character): ?int

Returns the Unicode code point value of the given character.

This function complements IntlChar::chr().

Параметри

character

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

Значення, що повертаються

Returns the Unicode code point value as an integer.

Приклади

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

<?php
var_dump
(IntlChar::ord("A"));
var_dump(IntlChar::ord(" "));
var_dump(IntlChar::ord("\u{2603}"));
?>

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

int(65)
int(32)
int(9731)

Прогляньте також

  • IntlChar::chr() - Return Unicode character by code point value
  • mb_ord() - Get Unicode code point of character
  • ord() - Convert the first byte of a string to a value between 0 and 255

add a note

User Contributed Notes

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