编码问题标题

时间:2011-01-16 15:11:05

标签: php encoding utf-8 diacritics htmlspecialchars

我的标签与PHP结合有点问题。我的代码是:

$title = '....';
echo '<title>'.htmlspecialchars($title).'</title>';

当我使用"Niederländische Zitate"浏览器输出“Niederl ndischeZitate”时 当我使用"Niederl&auml;ndische Zitate"时,浏览器输出“NiederländischeZitate”

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

任何人都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

除了元标记,您还需要:

a)像这样发送UTF-8 header

 header ('Content-type: text/html; charset=utf-8');

在你的剧本的最开始。

b)并将脚本文件另存为UTF-8 without BOM编码。使用任何好的代码编辑器,比如Notepad ++允许这样做。