Page 1 of 1

Header problem(Solved to some extent) UTF-8

Posted: Fri Feb 23, 2007 4:30 am
by user___
Hi guys,
I am creating a forum but I have a problem with a heading. I am sure that there is not any output(No spaces before or after "<?php" and "?>", I have a presentation layer which dows not make any mess, etc.). I wonder whether there is a way to track headers or ...

I have this error displayed:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\apache\forum\scripts\main_forum.php:1) in C:\Program Files\Apache Group\apache\forum\config\config.php on line 136
In main_forum.php I have a class which declares others and has nothing to do with the output and in config.php I create a cookie at this line(This file has only constants).

Reply

Posted: Fri Feb 23, 2007 5:00 am
by user___
Hi guys,
I have solved it. The problem comes from the Encoding(weird). FIrst I had had my files encoded in ANSI. Then I decided to set them to UTF-8 and I got the problem.
Doesn anyone know why is this the case and how remove this problem?

Posted: Fri Feb 23, 2007 5:17 am
by onion2k
Very odd. Have you checked headers_sent()?

Reply

Posted: Fri Feb 23, 2007 5:35 am
by user___
Yes, I have checked header_sent(). The problem comes from the Encoding. BTW I have only classes in the files I tried t encode.

Posted: Fri Feb 23, 2007 5:39 am
by Kieran Huggins
It's likely sending the Byte-Order Mark (or BOM). It's a 2 or 3 byte string prepended to Unicode files that indicate the byte order of and/or the encoding. It's supposed to be invisible, but seems to cause more problems with UTF-8 documents in practice then it solves.

You should be able to tell your editor not to put the BOM in your file, there's a setting somewhere in mine I switched off once.

Posted: Fri Feb 23, 2007 6:02 am
by Mordred
Your editor sucks ;)

Some editors put two characters called BOM, byte order mark in the beginning of UTF8 encoded text files. They are invisible when opened with the editor, because it just uses them to tell that the file is in utf8, but PHP doesn't like them and echo-es them as output.

Try a different editor, for example Scite has file->encoding->utf-8 cookie.

Reply

Posted: Fri Feb 23, 2007 6:41 am
by user___
I use EditPlus 2.30 and I had not had any problems before this with the encoding. I will try what you have said guys and I will tell you what the result is.

Reply

Posted: Fri Feb 23, 2007 6:49 am
by user___
Thank you guys. I have made it work. That was the problem.

Posted: Fri Feb 23, 2007 7:06 am
by Kieran Huggins
For the record (and future searches), in EditPlus the setting is:

Tools -> Preferences -> Files -> UTF-8 Signature = "Preserve Existing Signature"