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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:27:27
Original
1676 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template