php equivlent of fromCharCode?

依然范特西╮ 提交于 2019-12-29 06:25:45

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/9878483/php-equivlent-of-fromcharcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!