首页 >后端开发 >php教程 >javascript的String.fromCharCode(252)和PHP的chr(252)得到的结果不一样咋办?

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-06 20:27:271676浏览

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>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn