[英]character encoding of the HTML document was not declared codeigniter
My CodeIgniter app has started to a freak error: 我的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.
In the first visit, the page appears fine, just a message "guimbu" . 在第一次访问时,页面显示正常,只是一条消息“guimbu” 。 If you refresh the page, the error appears until you clear the history of browser.
如果刷新页面,则会在清除浏览器历史记录之前显示错误。 This happens only after second page-view.
这仅在第二次页面查看后发生。 Take a look: http://guimbu.com/soon
看看: http : //guimbu.com/soon
My autoload.php has this: 我的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();
How can I debug this problem? 我该如何调试这个问题?
UPDATE: 更新:
@sudhir, thanks for the answer, but I tried this many times. @sudhir,谢谢你的回答,但我多次尝试过。 Actually the source code is just:
实际上源代码只是:
<!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>
And the error persists after second page-view =/ Maybe a problem with sessions? 并且在第二次页面查看后错误仍然存在= /可能是会话有问题?
UPDATE with possibility: 更新可能性:
When I remove session and auth libraries from autoload , the problem doesn't happen. 当我从autoload中删除会话和auth库时,问题不会发生。 WTF?
WTF? auth is a library I made for user authentication.
auth是我为用户身份验证而创建的库。
When you refresh that page you get a blank one, if you view source that page you'll see it's blank that is has a number count. 当您刷新该页面时,您会得到一个空白页面,如果您查看该页面的来源 ,您将看到它是空白的,具有数字计数。 My guess is that you're doing something when the page refreshes that sends a white space to the browser.
我的猜测是,当页面刷新时会向浏览器发送一个空白区域。 I can only suggest not to close your files with
?>
and let php handle how your scripts will exit/die. 我只能建议不要用
?>
关闭你的文件,让php处理你的脚本退出/死亡的方式。 There's some whitespace in your code that's causing that. 你的代码中有一些空格导致了这一点。
try adding these in head section of your view: 尝试在视图的head部分添加这些:
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
FOUND SOLUTION 找到解决方案
In the first lines of Session class constructor, it loads the String helper. 在Session类构造函数的第一行中,它加载String helper。 Yesterday I've created a helper called string_helper.php and this conflict was what crashing application.
昨天我创建了一个名为string_helper.php的帮手,这个冲突就是崩溃的应用程序。
I renamed my string_helper.php file and now everything works fine. 我重命名了我的string_helper.php文件,现在一切正常。
Thanks all! 谢谢大家!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.