Home >Backend Development >PHP Tutorial >javascript的String.fromCharCode(252)和PHP的chr(252)得到的结果不一样咋办?

javascript的String.fromCharCode(252)和PHP的chr(252)得到的结果不一样咋办?

WBOY
WBOYOriginal
2016-06-06 20:27:271671browse

javascript的
String.fromCharCode(252)
和PHP的
chr(252)得到的结果不一样咋办?

回复内容:

javascript的
String.fromCharCode(252)
和PHP的
chr(252)得到的结果不一样咋办?

<code class="php">//chr() with unicode support
function uchr ($codes) {
    if (is_scalar($codes)) $codes= func_get_args();
    $str= '';
    foreach ($codes as $code) $str.= html_entity_decode(''.$code.';',ENT_NOQUOTES,'UTF-8');
    return $str;
}
echo uchr(252);//输出和String.fromCharCode(252)相同了</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn