Translate php directions for the designer? Comment with a Unicode-character inside?

I’m on a shared server with PHP5 my files are encoded in UTF-8. I developed the site in html first and it checks out fine in the browser. I used php for simple file includes and now I am seeing a strange space at the top of my pages (until it’s refreshed). Doing some research I have found that UTF-8 Files are usually encoded with BOM (some characters in front of the file) which causes extra space at the top of the page. I have tried to convert my files to UTF-8 without BOM but it’s not solving the problem. I’ve since come across the following fix but I don’t understand what the php code should be?

FIX: “for people using PHP on windows or others hosting on a shared public webserver, there are other workarounds: the first line in your PHP code should be a comment with a Unicode-character inside, like german “Umlaute”, for example. then you save this file as UTF-8 without BOM. the editor should now recognize the special character as UTF-8 encoded and switch to the right encoding.”

Can someone translate?

cut + paste all but the first character into a new file.

You can include this at the top of your pages to serve them as Unicode:

<?php header('Content-Type: text/html; charset=utf-8'); ?>

It needs to be before any output, even whitespace though or it’ll cause a 'headers already sent’ error.

The ideal method is to set your web server up to issue the header, but that might not be an option on shared hosting.

Sorry, I just realised I’d completely missed the point about it being PHP includes!

I haven’t seen it occur very often, most PHP installations are compiled with ‘Zend Multibyte Support’ which fixes this issue. Again, not an option on shared hosting though.

As an alternative to stripping it from each file; you could use output buffering, and then do a str_replace to get rid of them.

(This did have links to the PHP manual. but I’m not allowed to post links yet!)