I've come across an encoding problem with PHP, and am looking for help from anyone with experience of character encoding and PHP. When I save a file in UTF format, it seems to automatically send headers to the client, resulting in an error when I try to use the
Author: Gez Lemon
I've converted the colour contrast analyser from ASP to PHP. I've also converted the Spanish version of the colour contrast analyser, which works fine locally, but breaks when I load it to the server.
The error I am getting is a warning that the headers have already been written when I try to set the character encoding with the
header function. The headers shouldn't have been written at that point, and aren't on my machine at home. The only thing I can guess is that because the file is saved in UTF, somewhere along the line, headers are being written and sent to the client. I tried turning on buffering with
ob_start, and flushing after I'd collected the headers with
ob_end_flush, but that still resulted in the same error, possibly confirming that the headers are being written somewhere else, based purely on the character encoding of the source file.
The Spanish version of the colour contrast analyser is loaded on the server, but saved in ANSI to avoid the header problem. The characters no longer display correctly due to the incorrect character encoding. Does anyone have any ideas what could be causing this, and how to resolve it?