2

Now this is the most weird problem I've ever had in PHP.

All pages looks normal except one; when I first saw the problem I thought it was one of these common problems with IE and stylesheets (I've got a specific CSS-file on this page). I tried to exclude the CSS-file just to ensure that the problem really was in this file, but it wasn't. Then I thought I had forgotten to close any HTML tag, so I went through the code multiple times, but all seemed to be correct. So I started to put code in comments and compare with IE until I realized that when I putted the following code in a comment, the page itself acted normal:

require_once(PATH_INCLUDES . 'adjacency.php');

It's a valid path, and the file does just contain a class with functions - there's no output in any way except die() if a MySQL query fails.

Some things that look weird in IE are the following:

  • The container is normally centered, now it's at the left.
  • A background with repeat-x doesn't go all the way.
  • The hover functionality in the menu doesn't work.

Anyone?

Edit: I tried to include adjacency.php in another file, and the same problem occurred.

Ivar
  • 4,344
  • 6
  • 38
  • 53

2 Answers2

5

As a guess, there's most likely some space at the end of the include file after the closing "?>". (One of the reasons that Zend Framework recommends not using the closing PHP tag.)

John Parker
  • 54,048
  • 11
  • 129
  • 129
  • 2
    probably the cause, any output before the doctype triggers quirksmode in IE6 – I.devries Jul 30 '09 at 20:26
  • I thought that too, so I checked that and even, in IE, right-click->source. Nothing is before the doctype. – Ivar Jul 30 '09 at 20:27
  • 1
    I'd check the beginning and end of the include file just to be sure - it might be a non-display character that's causing the problem. – John Parker Jul 30 '09 at 20:36
  • Checked and confirmed - there's no character before or after the PHP section. – Ivar Jul 30 '09 at 21:44
  • I'm curious about this not 'closing the php tag'. Could you please provide a link to this statement? I'd like to read it in context. Thanks! – EvilChookie Jul 30 '09 at 21:58
  • Please double-check. Save each version and compare byte for byte using fc (command-line utility that comes with Windows) or a similar tool. Also try viewing the saved versions in your browser and see whether the same thing happens. And see also my answer. – Stewart Jul 30 '09 at 21:59
  • What files should I compare with fc? – Ivar Jul 30 '09 at 22:32
  • The HTML file generated by your PHP script with the require_once, and the HTML file generated by your PHP script without the require_once. Make sure you save each as "Webpage, HTML only". – Stewart Jul 30 '09 at 22:50
  • @EvilChookie - It's in the coding standards at http://framework.zend.com/manual/en/coding-standard.html - See the "PHP File Formatting" section. – John Parker Jul 31 '09 at 07:12
1

Does the included PHP file begin with a UTF-8 BOM (byte order mark)? This is an invisible byte sequence that sometimes appears at the beginning of a Unicode text file to aid auto-detection of the UTF. Unfortunately, PHP is somewhat naive, and will output the BOM as and when it reads it in from an included PHP file. By my experiment, IE can handle one BOM, but if the BOM is doubled (as will be the case if the PHP file the browser requested and one included each contain the BOM) then it fails to see the doctype as being at the beginning and thus quirks mode is triggered.

Make sure your editor is configured to save without BOMs.

Stewart
  • 3,935
  • 4
  • 27
  • 36