PHP session with UTF-8-BOM encoding

ε祈祈猫儿з 提交于 2020-02-08 10:24:27

问题


I have created one php page with UTF-8-BOM encoding. I want to use this encoding because I have some content which are in my regional language, and do display it properly i need to use UTF-8-BOM encoding.

Now I want to use session with this page but it is throwing error of headers already set.

So is there any way i can use both together.

If I am trying to use UTF-8 only I am not getting problem displaying data in regional format.

See Attached Image


回答1:


The "Byte Order Mark" is a sequence of 3 bytes that a file begins with, making it pretty much incompatible with PHP, because a script that is supposed to contain only PHP code must start with the <?php tag instead.

Obviously, it's not like the whole thing doesn't work at all, but anything that involves sending HTTP headers (which is A LOT) automatically gets broken.

Sessions use cookies - transferred via headers - won't work.
Redirecting to another page - the Location header - won't work.
Dynamically generated downloads - the downloaded file itself will be broken.

etc.

Sorry, but you'll have to give up on BOM and figure another way to handle your locale-specific data (which I can only assume is using another charset for whatever reason).



来源:https://stackoverflow.com/questions/35114000/php-session-with-utf-8-bom-encoding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!