繁体   English   中英

HTML文档的字符编码未声明为codeigniter

[英]character encoding of the HTML document was not declared codeigniter

我的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; 两次。
  • 我刚试过所有charset元标记;
  • 所有页面都会发生这种情况,包括这个简单的页面

我的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中删除会话auth库时,问题不会发生。 WTF? auth是我为用户身份验证而创建的库。

当您刷新该页面时,您会得到一个空白页面,如果您查看该页面的来源 ,您将看到它是空白的,具有数字计数。 我的猜测是,当页面刷新时会向浏览器发送一个空白区域。 我只能建议不要用?>关闭你的文件,让php处理你的脚本退出/死亡的方式。 你的代码中有一些空格导致了这一点。

尝试在视图的head部分添加这些:

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

找到解决方案

在Session类构造函数的第一行中,它加载String helper。 昨天我创建了一个名为string_helper.php的帮手,这个冲突就是崩溃的应用程序。

我重命名了我的string_helper.php文件,现在一切正常。

谢谢大家!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM