Dutch PHP Conference 2025 - Call For Papers

mb_chr

(PHP 7 >= 7.2.0, PHP 8)

mb_chrReturn character by Unicode code point value

Опис

mb_chr(int $codepoint, ?string $encoding = null): string|false

Returns a string containing the character specified by the Unicode code point value, encoded in the specified encoding.

This function complements mb_ord().

Параметри

codepoint

A Unicode codepoint value, e.g. 128024 for U+1F418 ELEPHANT

encoding

Параметром encoding вказується кодування символів. Якщо він пропущений або null, використається внутрішнє кодування.

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

A string containing the requested character, if it can be represented in the specified encoding або false в разі помилки.

Журнал змін

Версія Опис
8.0.0 encoding тепер може бути null.

Приклади

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

<?php
$values
= [65, 63, 0x20AC, 128024];
foreach (
$values as $value) {
var_dump(mb_chr($value, 'UTF-8'));
var_dump(mb_chr($value, 'ISO-8859-1'));
}
?>

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

string(1) "A"
string(1) "A"
string(1) "?"
string(1) "?"
string(3) "€"
bool(false)
string(4) "🐘"
bool(false)

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

add a note

User Contributed Notes

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