mb_chr

(PHP 7 >= 7.2.0, PHP 8)

mb_chrReturn character by Unicode code point value

˵Ã÷

mb_chr ( int $codepoint , string|null $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¡£

·¶Àý

Example #1 Testing different code points

<?php
$values 
= [65630x20AC128024];
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)

²Î¼û

User Contributed Notes

There are no user contributed notes for this page.
PHP8ÖÐÎÄÊÖ²á ÓÉ Õ¾³¤ÔÚÏß ÕûÀí °æȨ¹éPHPÎĵµ×éËùÓÐ