PHP session_start() with includes

On one of my websites, I need to use session_start(), but I keep getting these errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\index.php:1) in C:\xampp\htdocs\index.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\index.php:1) in C:\xampp\htdocs\index.php on line 1

session_start() is right after the PHP opening tag at the start of the page, but the code that’s causing the problem seems to be that each page that uses session_start() also includes header.inc.php, which in turn includes html_header.inc.php. The only way I found to make it work is to turn on output_buffering in php.ini, but there must be a better solution. Here’s my code:

index.php


<?php session_start(); $page_title = 'Home'; include('header.inc.php'); ?> 
      <div id="body">
        <h2>Lorem Ipsum</h2>
      </div>
    </div>
  </body>
</html>

header.inc.php


<?php include('html_header.inc.php'); ?>
  <body>
    <div id="page">
      <div id="header">
        <h1>Lorem Ipsum</h1>
     </div>

html_header.inc.php


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title><?php echo $page_title; ?></title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-style-type" content="text/css" />
    <meta name="language" content="XHTML 1.1" />
    <!-- This Page is Valid XHTML 1.1 -->
    <style type="text/css">
      * {
        font-family: "Trebuchet MS", Tahoma, "Microsoft Sans Serif", sans-serif;
        background: #f5f5dc;
      }
      html, body {
        background: #B2CDE0;
        margin: 0;
        padding: 0;
      }
      #page {
        padding: 3em;
        width: 65%;
        min-width: 400px;
        margin: 0 auto;
        background: #F5F5DC;
      }
      #header {
        text-align: center;
      }
    </style>
  </head>

I would appreciate any help. Thanks!

It now works - thanks for your speedy reply!
But on a side note, what is a BOM and how does it affect the web page?

Probably because of a BOM. Change the encoding in the editor to “UTF8 without BOM”.

tl;dr - it puts some invisible characters at the beginning of your document, these are sent to the browser, output has started and headers can not be sent anymore.