我的CodeIgniter应用程序出现了一个奇怪的错误:
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
在第一次访问时,页面看起来很好,只有一个消息“ guimbu”。如果刷新页面,则出现错误,直到清除浏览器的历史记录为止。这只会在第二个页面查看后发生。请看:http://guimbu.com/soon
- 我刚刚用Sublime打开了所有文件,并保存为UTF-8;两次。
- 我刚刚尝试使用所有字符集meta标签;
- 这对于所有页面都是如此,包括这个简单的页面;
我的autoload.php如下:
$autoload['packages'] = array();
$autoload['libraries'] = array('session', 'database', 'firephp', 'auth');
$autoload['helper'] = array('url', 'log_helper', 'api_helper', 'string_helper');
$autoload['config'] = array('ci_opauth', 'rest', 'ci_auth');
$autoload['language'] = array();
$autoload['model'] = array();
我该如何调试这个问题?
更新:
@sudhir,感谢你的回答,但我已经尝试了很多次。实际上,源代码只是:
<!DOCTYPE html>
<head>
<title>guimbu</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
guimbu =)
</body>
</html>
第二次页面加载后错误仍然存在 =/ 可能是会话的问题吗?
更新可能性:
当我从autoload中删除session和auth库时,问题就不会出现。什么鬼?auth是我用于用户认证的库。