Re: HTTP headers and include()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
At 12:24 AM -0700 7/10/09, James Colannino wrote:
Eddie Drapkin wrote:

 HTTP headers are sent and finalized after the first bit of output.   I
 had the same problem before and it turned out to be because I had a
 close tag "?>" at the end of a file followed by some whitespace.  The
 solution was to remove the ?> from the end of all the files and I
 haven't closed an entire file since.  Perhaps that might be it?

Hmm...  In fact, I did close all my include files with the ?> tag, and
per Michael's observation in another response, there is a line of
whitespace after the closing tag in my include files.

I tried getting rid of the trailing whitespace, and removed the closing
tags.  Unfortunately, even after that, when I place my include files
before session_start, I get the same problem.  There's no leading
whitespace before the starting <?php tag, so I'm still a little at a loss.

It's not too big of a deal though; I simply placed my include files
after the call to session_start().  That seems to solve the problem.

James


James:

As I understand things, that's the way it is supposed to work -- you always start a session page off with session_start() as your first statement.

I've had some pages complain that a session has already been started and in that case, I check to see if a session ID is set and it not, then do a session_start().

But, as a matter of habit, I always make session_start() my first line of code.

Cheers,

tedd


If the included file has

<?php
somefunc() {
  }
?>

<?php
somefunc() {
  }
?>

that will also cause it.
Or maybe one of the include files includes a file (IE db connection script) that has white space.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux