Search code examples
phphtmlfileinternet-explorerbyte-order-mark

BOM before doctype due to PHP file management functions


I have asked here why my page was not working in IE. The answer was that i had a byte just before the doctype.

However, i check it and re-check it, there is no a white space before doctype, i saved the document as ANSI, as UTF-8 without BOM (all of the with notepad) and it does not go away.

But, i was able to collect some interesting data. My website uses for displaying the content templates. If i select the header (where the problem is) and display it directly in IE, it works!

So i think the bit is added when the files are read from php and displayed. PHP codes for displaying the content:

    function gettemplate ($templatename) {
        $filename = './templates/'. $templatename . ".tpl";
        return ReadFromFile($filename);
    }

The extension of the files is .tpl but it works exactly the same as if it was .html (i have checked it)

How can i solve this issue?


Solution

  • When I do a hexdump of your Page:

    $ GET http://juancarlosoleacañizares.es/ | hd | head -n 1
    00000000  ef bb bf ef bb bf 3c 21  44 4f 43 54 59 50 45 20  |......<!DOCTYPE |
    

    I see two BOM-Markers (two times EF BB BF) which is unusual. Have you checked if the .php-files themselves have BOM-Markers?