问题
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