加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 16:49:46 所属栏目:PHP教程 来源:网络整理
导读:我的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-A
我的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处理你的脚本退出/死亡的方式.你的代码中有一些空格导致了这一点.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读