Php XMLHttpRequest:输出UTF8

Php XMLHttpRequest:输出UTF8,php,javascript,ajax,utf-8,Php,Javascript,Ajax,Utf 8,我有一个简单的XMLHttpRequest请求 if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() {

我有一个简单的XMLHttpRequest请求

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
 {
 document.getElementById(divID).innerHTML=xmlhttp.responseText;
 }
xmlhttp.open("GET","page.php?q="+str,true);
xmlhttp.send();
当我尝试在AJAX页面(page.php)中打印文本时,它会返回一些奇怪的结果

echo "éééé";
但是,如果我使用utf8_encode(),则一切正常:

$string=utf8_encode("ééé");
echo $string;
现在我的问题是,我怎样才能把整个页面变成utf8?我希望我的é是正确的,而不必对输出的每个字符串使用utf8_encode()。它可以在我所有的页面上运行,除了ajax中的页面。他们都像

<?php
session_start();
code
?>

但它不起作用。

您确定您的内容类型不会恢复为UTF-8吗?(提示:检查firebug或其他标题分析器)。这可能也会有帮助:使用utf-8编码保存源文件。@RobW fire bug非常有用,谢谢
header('Content-Type: text/html; charset=utf-8');