Home > php教程 > php手册 > PHP中Unicode的签名问题

PHP中Unicode的签名问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:36:03
Original
839 people have browsed it

  被 WordPress 模板的怪异代码空行折腾半天。

  因为 Dansion 师兄的驱使,开始 Dreamweaver 征途。不过很少有人关注到,在 Dreamweaver 中使用 utf-8 编码保存时,默认会有 "Unicode 标准化表单" 和 "包括 Unicode 签名 (BOM)" 两个选项,在页面属性里也可以看到:

  如果 "包括 Unicode 签名" 选项被勾选,会产生稀奇古怪的页面渲染问题。

  什么是 Unicode 签名 (BOM)?

  BOM (Byte Order Mark) 是 UTF 编码方案里用于标识编码的标准标记。位于文本文件开头的 2 到 4 个字节,可将文件标识为 Unicode,还标识后面字节的字节顺序。由于 UTF-8 没有字节顺序,因此可以选择添加 UTF-8 BOM。对于 UTF-16 和 UTF-32,这是必需的。

  由于这个 BOM 的存在,PHP 会误认为文本内容已经输出,因此会对页面渲染造成影响。据说 PHP6 中已经修复这个问题。

  如何防止 Unicode 签名 (BOM) 对页面渲染的影响?

  以 Dreamweaver 为例,保存 utf-8 编码的文档时,不勾选 "包括 Unicode 签名 (BOM)" 选项即可。

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