在PHP实现后,标题被取代(UTF-8 BOM)

My company had a decent website before I joined them, outsourced and untouched for years since. After joining I've been slowly improving it in my free-time.

This week I rewrote the header/left-column/footer which are the same on all pages so that I could include them using PHP and avoid fixing them one-by-one when I want to change something (among other benefits).

I'm not well-versed in messing with the .htaccess nor PHP but really all that I have changed is:

  1. Allowing PHP to work with .html files by adding to .htaccess:

AddType application/x-httpd-php5 .html .htm

  1. I changed:

<?xml version="1.0" encoding="UTF-8"?>

To:

<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> ";?>

To avoid the <?xml tag from throwing PHP short tag errors

  1. copy and pasted the three common elements, header, left-column, and footer into separate HTML files and and included them using:

<?php include '_header.html';?>

  1. changed the upper left text a little, but that shouldn't affect anything.

Looking at the source code after loading both pages (PHP include and plain html) they look identical. I haven't changed any of the CSS and so they are using the same code.

Yet for some reason switching to the PHP include version adds an empty line at the top of the page.

Here is the current (plain XHTML) version: http://www.akidc.co.jp/index.html The new file for reference is: ((removed outdated link)) (I can't change the .htaccess until I upload all the new pages at once or the <?xml tag will error them all so it's up'd as a .php)

The header file I'm including is at _header.html

Please help me solve the gap ^_^

Run a diff on the source, you'll immediately notice what's going here.

In the PHP version, you have a U+FEFF just before the <div id="header" ...>. This is interpreted as content by the browser, so it attempts to display this content.

In order to solve the issue, make sure all your source code is stored in UTF-8 format.

By the way, here's the diff:

enter image description here

See that <feff>?

And now, look at the elements of your page. This is what you had before:

enter image description here

and this is what you get in PHP version:

enter image description here

Notice the additional " " block I highlighted?