简体   繁体   English

PHP session_start,使用'UTF-8无BOM'显示日文字符而不会弄乱标题

[英]PHP session_start, Displaying Japanese characters using 'UTF-8 without BOM' without messing up headers

Alright, so I'm using Notepad++ to write up a webpage that contains both English and Japanese characters. 好吧,所以我使用Notepad ++编写一个包含英文和日文字符的网页。 The website also uses PHP sessions. 该网站还使用PHP会话。

After wracking my brain for a while wondering why I was getting this error: 在震撼了我的大脑一段时间后,我想知道为什么我会收到这个错误:

'Cannot send session cache limiter - headers already sent' 

I realized that because I was using 'Encode in UTF-8', the invisible BOM output was screwing up my PHP headers. 我意识到,因为我使用'UTF-8编码',看不见的BOM输出搞砸了我的PHP标题。

So I switched to 'Encode in UTF-8 without BOM' in Notepad++. 所以我在Notepad ++中切换到“没有BOM的UTF-8编码”。 Now my PHP sessions work and it doesn't complain about headers, but now Japanese characters don't properly display on the website (although they appear just fine in Notepad++). 现在我的PHP会话工作,并没有抱怨标题,但现在日语字符没有正确显示在网站上(虽然它们在Notepad ++中显得很好)。 I traded one problem for another. 我把另一个问题换成了问题。

How can I get Japanese characters to properly display on my website while still avoiding the UTF-8 encoding issue of sending output before PHP session_start? 如何在我的网站上正确显示日文字符,同时仍然避免在PHP session_start之前发送输出的UTF-8编码问题?

尝试将addDefaultCharset UTF-8添加到应用程序根目录中的.htaccess文件中

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

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