Amir
Amir

Reputation: 1259

including php file change layout?

i have the strangest bug. in my php file i include several php files:

<?php
include("a.php");
include("b.php");
include("c.php");
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="src/main.css" ></link>
<script src="src/jquery-1.3.2.js" type="text/javascript" ></script>
</head>
<body>
some more code here...

when the page is rendered, i see that there are about 18px added to the layout, and the link and script tags were moved inside the body section. If i remove the include of b.php and c.php it doesn't happen.

any thoughts?

Upvotes: 0

Views: 245

Answers (2)

Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53607

  1. check for BOM.
  2. Check for white spaces in your files
  3. make sure to remove the ending ?> from your PHP files, if this is the last characters in the file.

4. do

 ?><html>

instead of

?>
<html>

Upvotes: 2

nickf
nickf

Reputation: 546143

Check there's no whitespace at the end of the included files after you final closing ?>. The easiest way to be sure there's nothing after that is to remove it altogether:

<?php
// here is my file
// and i don't have to close the PHP tag
// woo

Upvotes: 0

Related Questions