問題描述
我有一個(gè)文件,我遇到了一個(gè)非常奇怪的錯(cuò)誤.錯(cuò)誤是:
I have a file that I am getting a very weird error on. The error is:
它來自的文件是(indexmws.php):
the file this comes from is (indexmws.php):
這是一個(gè)不會(huì)拋出錯(cuò)誤的文件 (index.php) 的完全副本,除了添加 amazonPricingMWS.php 并重定向到標(biāo)題中帶有 mws.php 的頁面:
This is an exact duplicate of a file that does not throw the error (index.php)with the exception of adding amazonPricingMWS.php and redirecting to pages with mws.php in the title:
誰能向我解釋為什么我在 indexmws.php 中收到此錯(cuò)誤?
can anyone explain to me why I am getting this error in indexmws.php?
推薦答案
出現(xiàn)錯(cuò)誤是因?yàn)闉g覽器需要文件的前 1024 個(gè)字節(jié)的編碼格式.可能是第一種情況下包含文件輸出了一些內(nèi)容.
The error is coming because the browsers expect the encoding format in the first 1024 bytes of the file. It may be the case that there is some content being outputted by the included files in the first case.
瀏覽器現(xiàn)在緩沖文件的前 1024 個(gè)字節(jié)以檢查字符編碼.如果在前 1024 個(gè)字節(jié)中未遇到編碼描述,則顯示此警告.
The browsers now buffer the first 1024 bytes of the file to check for the character encoding. If the encoding description is not encountered in the first 1024 bytes, this warning is displayed.
在您的情況下,您可以使用 php 標(biāo)頭在包含其他文件之前指定內(nèi)容類型:
In your case, you can use a php header for specifying the content type before the other files are included:
欲了解更多信息,請(qǐng)閱讀:http://gtmetrix.com/specify-a-character-set-early.html
For more information, read this: http://gtmetrix.com/specify-a-character-set-early.html
這篇關(guān)于未在 html 文檔中聲明的字符編碼的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!