What is the PHP equivlent of fromCharCode?

后端 未结 2 951
执念已碎
执念已碎 2020-12-17 02:15

Is there a PHP function that takes an integer and return the Unicode character of that number?

相关标签:
2条回答
  • 2020-12-17 02:56

    No, but you can easily make one:

    <?php
    /**
     * Return unicode char by its code
     *
     * @param int $u
     * @return char
     */
    function unichr($u) {
        return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
    }
    ?>
    

    Taken from: PHP Manual - chr - comments

    0 讨论(0)
  • 2020-12-17 03:05

    Look at this: http://php.net/manual/en/function.utf8-encode.php

    0 讨论(0)
提交回复
热议问题