Hi everyone, I'm having a problem using PHP includes. Essentially I am trying to move away from Dreamweaver Templates and create a site using PHP Includes. So Far So Good, however I am getting gaps in Firefox and IE7 (Doesn't happen on Safari) in between PHP Includes. These gaps cannot be remedied by CSS or deleting blank lines or spaces. The bizzare thing is that even output HTML looks like it shouldn't produce a gap. When I copy and paste all of my includes onto a single html page, and upload the to the server, I get no gaps. Here is my primary includes page code: <?php require('includes/header.php'); ?> <title>Hello</title> <?php require('includes/header2.php'); ?> <h1>Test Page</h1> <p>test</p> <?php require('includes/footer.php'); ?> PHP: header PHP is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> PHP: Header 2 is: <link rel="stylesheet" type="text/css" href="<?php PHP_SELF ?>/css/styles.css"/> </head><body> PHP: and so on. Essentially I'm getting about 10-15px gap at the very top of the page. Does anyone know what causes this problem, and how I can fix it? The outputted page can be seen here so that you can see the gap: http://www.crearedesign.co.uk/contact-us.php The White tab at the top should not have that gap above it. I'm using Dreamweaver CS4 For Mac. Thank you in advance.
This is a css issue and not a php issue. I would mess with the css for the header element or possibly the body element until you get it removed.
It's not a CSS issue. Like I said, If I open all of my include files, copy and paste them onto a single html page, upload the page, there is no gap at the top. http://www.crearedesign.co.uk/cont.php The gap IMO has something to do with the includes. Both the link in my initial post, and the link just above, are the same files, using the same CSS.
If I use winmerge to compare the 2, the one that displays incorrectly, has hidden characters in it. There is one as the first character in the include file. I can't tell what character it is. Is appears as a dot, and doesn't appear to have any encoding with it. What program are you using to write these files?
jestep, thank you for your help, your discovery looks like it could be the problem. I'm using Dreamweaver CS4 for Mac to code and upload everything. Does anyone know how to 'save files with no BOM.' in Dreamweaver? Thanks again to everyone for the assistance.
I don't know anything about Dreamweaver (never tried GUI web tools) but there's definitely a BOM at the head of your file: % wget -q -O - http://www.crearedesign.co.uk/cont.php | od -a | head -n 1 0000000 ef bb bf < ! D O C T Y P E sp h t m Code (markup): That EF BB BF is the giveaway. I'm surprised Dreamweaver would put it in, as it's so often a problem for web and particularly PHP files. Maybe you'll find something in the preferences or the "save as" dialog about "byte order mark" or "unicode signature". If so, just turn it off.