Re: HTTP headers and include()
| From: | Michael A. Peters | Date: | Fri, 10 Jul 2009 05:49:49 +0000 |
| Subject: | Re: HTTP headers and include() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295127@lists.php.net to get a copy of this message | ||
James Colannino wrote:
Hey everyone, I've been hard at work on a new web application, and discovered something that I would never have seen coming. I was noticing that when I called session_start() after a few lines of includes, I was getting complaints because the HTTP headers had already been sent out. Then, after putting session_start() above the include lines, suddenly everything was working fine. The files that were included were nothing more than functions; there was no code executing that I could tell up to the point of the call to session_start(). I was just wondering if anybody on the list knows why HTTP headers were being sent out by my includes. I'm sure there's a good reason. I'm just very curious :) Thanks very much in advance. JamesWhite space can cause this - make sure your code has <?php as the very top and ?> at the very bottom, or the white space may trigger the web server to send a header and the white space as data before the cookie for session_start() is sent.