php - eclipse中无BOM编码的utf8

标签 php eclipse byte-order-mark

经过一番头痛之后,我发现 Eclipse 使用设置编码 UTF8(带 BOM)会导致错误。当您使用 include 时,它​​会导致添加空格,导致网页标题在 Chrome 的正文中呈现。

即。在index.php上,当然之前或之​​后没有间隙

<?php include_once('header.php'); ?><body>test</body>

和 header.php 有(当然又没有间隙)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test title</title>
</head>

然后测试标题出现在正文中(不是在查看源代码中,而是在 chrome 的控制台中)。这会导致页面顶部出现间隙。

用notepad++打开index.php和header.php,将编码改为UTF8无BOM即可解决。 如何在 Eclipse 中解决这个问题?! 切换到 notepad++ 是不可取的,Eclipse 中有太多有用的好功能(更好的自动完成、自动版本控制等)。

对我来说是个谜......

最佳答案

在eclipse中,只需将文件的编码更改为iso(右键单击文件->属性)并删除前三个BOM字符,保存文件并重新打开即可。

关于php - eclipse中无BOM编码的utf8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10549445/

相关文章:

java - Eclipse 未在断点处停止 :Remote Java Debugging (done locally)

android - 删除 apk 后,每当我启动调试时,它都会告诉我未安装包

powershell - 如何在 PowerShell 中正确/全局地转换 UTF-8(无 BOM)文件? (到另一个文件)

php - Protobuf-PHP : Cannot Successfully Execute protoc-gen-php

php - FOS 用户/注册路径在 url 中有效但不作为路径

php - 在 PHP 中用换行符替换文字字符串\r\n 时出现问题

javascript internet explorer 字节顺序标记

php - 从 php 中的数据中删除损坏的 html 标签

java - Eclipse 中搜索结果的断点

unicode - 在 Go 中读取带有 BOM 的文件