Cannot modify header information - headers already sent in oop php
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8028957/headers-already-sent-by-php">Headers already sent by PHP</a>  </p>
</blockquote>



<p>I am new in object-oriented php. I have some problem that i can't solve. My problem is that when I want to log in/out then some error messages come out as shown below :: [note that it works well in functional php but problem is in oop php]</p>

<p>Error ::  </p>

<pre><code>Warning: Cannot modify header information - headers already sent by (output
started at E:\XAMPP\xampp\htdocs\photo_gallery_new\Includes\database_object.php:6)
in E:\XAMPP\xampp\htdocs\photo_gallery_new\Includes\Functions.php on line 14
</code></pre>

<p>My code ::  </p>

<p>index.php</p>

<pre><code>&lt;?php require_once ("../../Includes/initiate.php"); ?&gt; 
 &lt;?php
if( !$session-&gt;is_logged_in() ) {
    redirect_to("login.php");
}
?&gt; 
</code></pre>

<p>login.php</p>

<pre><code>&lt;?php   
require_once ("../../Includes/initiate.php");

if( $session-&gt;is_logged_in() ) {
    redirect_to("index.php");
}   
// Remember to give your form's submit tag a name="submit" attribute! 
if( isset($_POST['submit']) ) {  // form has been submitted
    $username = trim($_POST['username']); $password = trim($_POST['password']);     
    // Check database to see if username/password exist     
    $found_user = USER::authenticate($username, $password);     
    if($found_user) {
        $session-&gt;login($found_user);
        redirect_to("index.php");
    }  else {
        // username/password combo was not found in the database
        $message = "Username/password combination incorrect.";
    }
}   
else {   // form has not been submitted
    $username = "";
    $password = "";
}
?&gt;

&lt;html&gt; 
     &lt;----  form design [ form action = 'login.php' ] ---&gt;
&lt;/html&gt;
</code></pre>

<p>initiate.php</p>

<pre><code>  &lt;?php
      require_once ("session.php");
       require_once ("Config.php");
       require_once ("Functions.php");
      require_once ("Database.php");
     require_once ("database_object.php");  // this makes error
   require_once ("user.php");
  ?&gt;
</code></pre>

<p>function.php</p>

<pre><code>&lt;?php       
function strip_zeros_from_date( $marked_string="") {  .....   } 

function redirect_to( $location = NULL) {   // check loged in/not
    if($location != NULL) {
        header("Location: {$location}");  
        exit;
    }
}

function output_message($message = "") { ....   } 

function __autoload($class_name) {  ......   }

function include_layout_template( $template = "" ) { ...  }
 ?&gt;
</code></pre>

<p>initiate.php</p>

<pre><code> &lt;?php
require_once ("database.php");  
class databaseObject {      
}   
$newClass = new databaseObject();   
 ?&gt;
</code></pre>
