Home > Backend Development > PHP Tutorial > PHP把中文字符识别问数组?

PHP把中文字符识别问数组?

WBOY
Release: 2016-06-23 14:10:39
Original
1072 people have browsed it

看代码:

<?php//为什么这样可以输出'因'字?$n='因';$n=iconv("utf-8","gb2312",$n);echo $n[0];echo $n[1];?>
Copy after login

把你的浏览器编码调整为GB2312,页面输出'因'字,不解,为什么$n变成了一个数组了?


回复讨论(解决方案)

这不是数组,而是按偏移访问字符串的某个位置
为了防止误解,php建议你写作 $n{0}、$n{1}

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