PHP显示ISO-8859-1的utf-8

时间:2017-07-11 08:34:13

标签: php utf-8 iso-8859-1

如何正确显示$ string_result

中显示的$ string
$string = "À";
$string = html_entity_decode($string); //output as À
$string_result = "À";

echo "<br>This: " .  $string;
echo "<br>Should become: " . ($string_result);

输出

This: À
Should become: À

如果我在代码($ string_result)中硬编码,显示是正确的,但如果它是在变量($ string)中分配的,则它不会显示与$ string_result相同。

奇怪的是当我这样做时:

echo htmlentities($string);
echo htmlentities($string_result);

输出就像这样

&Atilde;&euro;
&Agrave;

1 个答案:

答案 0 :(得分:0)

添加标题:

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

在代码的开头。

相关问题