Home > Backend Development > PHP Tutorial > ord()的有关问题

ord()的有关问题

WBOY
Release: 2016-06-13 10:02:30
Original
1163 people have browsed it

ord()的问题
手册上面说是转换成ASCII,可是ASCII只有127个字符。为什么ord("我")依然可以输出结果呢。

------解决方案--------------------
who tell U ASCII只有127个?

加上扩展的应该有256个吧。

ord()是把字符串的第一个字符转为ASCII码。中文是双字节编码。
所以ord("我")只是“我”的第一个字符的ASCII码
------解决方案--------------------
$str = '我';
$o1 = ord($str);
$o2 = ord($str[0]);
//output $o1=230 $o2=230
手册上写的很清楚
返回字符串 string 第一个字符的 ASCII 码值。 

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template