views:

261

answers:

2

Somehow I managed to stick Ôªø at the top of a PHP script. What is that horrifying group of characters, how could I have entered it, and how can I expose and/or avoid it in the future?

Anecdotally, it was lurking at the very top of a PHP script, before <?php. The script needed to send a Content-type header. Because Ôªø pushed the header off the top of the file, the server kept sending its own header, and 2 hours of hilarity ensued. I couldn't even see the string in nano or bash. But I redirected a diff and there it was.

+3  A: 

That's most certainly an encoding error. Most likely, you're saving your script as one format, but uploading it or declaring it as another. I can't offer any further advice because I don't know much about encoding errors or how to fix them. Good luck squashing the bug.

Evan Kroske
+1 These can be a pain to crack. I've seen version control systems, editors, and differing OS versions all cause them.
BioBuckyBall
Just checked my local archives and it's there, so that rules out an upload issue. Used Dreamweaver CS4 Mac to edit it, IIRC. Defaults to UTF-8 with Unix endings.
scorxn
+5  A: 

That's UTF-8 byte order mark (look for EF BB BF). This is a standard thing and shouldn't cause you problems, but if it does then make sure your source code editor doesn't prepend the file with BOM when saving it.

Pawel Marciniak
That was my first thought, too. I suggest converting the file to UTF-8 without BOM and see if that works.
K Prime
The “UTF-8 BOM” isn't endorsed by the Unicode standard and as such it is no more than a zero-width-no-break-space when used in this way. Unfortunately many Microsoft tools write these bogus-BOMs to the front of UTF-8 files, breaking them in many tools.
bobince