Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_chr

Description

The mb_chr of Multibyte String for PHP return character by Unicode code point value.

Syntax

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

Parameters

codepoint

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

encoding

The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used.

Return

A string containing the requested character, if it can be represented in the specified encoding or false on failure.

Examples

1 · codepoint

<?

$codepoint = '128024';

$return = mb_chr($codepoint);

echo $return;

?>
🐘

2 · encoding

<?

$codepoint = '128024';
$encoding = 'UTF-8';

$return = mb_chr($codepoint, $encoding);

echo $return;

?>
<!doctype html>
<html>
<head>
    <title>PHP</title>
    <style>
        html, a
        {
            background-color: rgb(255 0 255 / 0.1);
        }
        a
        {
            color: purple;
            transition-duration: 1s;
        }
        a:hover
        {
            background-color: rgb(0 0 0 / 0.1);
            color: black;
            text-decoration-color: transparent;
        }
    </style>
</head>
<body>
    <a href="/php/">PHP</a>
    <script>
        function myfunction(myparameter)
        {
            const mytarget = myparameter.target;
            const mystyle = mytarget.style;
            mystyle.position = "absolute";
            mystyle.left = `${Math.random() * (window.innerWidth - mytarget.offsetWidth)}px`;
            mystyle.top = `${Math.random() * (window.innerHeight - mytarget.offsetHeight)}px`;
        }
        document.querySelector("a").addEventListener("mouseout", myfunction);
    </script>
</body>
</html>

3 · failure

<?

$codepoint = '128024';
$encoding = 'ISO-8859-1';

$return = mb_chr($codepoint, $encoding);

var_export($return);

?>
false
HomeMenu