Header problem(Solved to some extent) UTF-8

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Header problem(Solved to some extent) UTF-8

Post 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).
Last edited by user___ on Fri Feb 23, 2007 5:00 am, edited 1 time in total.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Very odd. Have you checked headers_sent()?
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post 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.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post 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.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

Thank you guys. I have made it work. That was the problem.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

For the record (and future searches), in EditPlus the setting is:

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