array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'es', ), 'this' => array ( 0 => 'function.mb-chr.php', 1 => 'mb_chr', ), 'up' => array ( 0 => 'ref.mbstring.php', 1 => 'Funciones de cadenas de caracteres multibyte', ), 'prev' => array ( 0 => 'function.mb-check-encoding.php', 1 => 'mb_check_encoding', ), 'next' => array ( 0 => 'function.mb-convert-case.php', 1 => 'mb_convert_case', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/mbstring/functions/mb-chr.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.2.0, PHP 8)
mb_chr — Return character by Unicode code point value
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
El parámetro encoding
es la codificación de caracteres. Si es omitido, será usado el valor de la
codificación de caracteres interna.
A string containing the requested character, if it can be represented in the specified
encoding o false
en caso de error.
Versión | Descripción |
---|---|
8.0.0 |
encoding is nullable now.
|
Ejemplo #1 Probar diferentes puntos de código
<?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'));
}
?>
El resultado del ejemplo sería:
string(1) "A" string(1) "A" string(1) "?" string(1) "?" string(3) "€" bool(false) string(4) "🐘" bool(false)