[英]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
我的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.