0

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

JP711
  • 93
  • 1
  • 10
  • No code no help possible – Mike Miller Jan 31 '16 at 12:52
  • Try UTF-8 without BOM – hisener Jan 31 '16 at 12:53
  • @hisener with UTF-8 without BOM I am getting error in displaying data. I have attached screenshot for same in my main post – JP711 Jan 31 '16 at 13:39
  • @MikeMiller I am not sure what kind of code i should pest here. – JP711 Jan 31 '16 at 13:40
  • The code that is causing the error would make sense – Mike Miller Jan 31 '16 at 13:43
  • @MikeMiller : before getting data from database I am using this query mysql_query ("set character_set_results='utf8'"); and as I have just encoded my PHP with UTF-8-BOM it is working fine. But when I am using session I am just writing SESSION_START() at top of page but it is giving me error of "headers are already set". – JP711 Jan 31 '16 at 13:48

1 Answers1

4

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).

Narf
  • 14,600
  • 3
  • 37
  • 66