Re: HTTP headers and include()
| From: | Eddie Drapkin | Date: | Fri, 10 Jul 2009 05:23:09 +0000 |
| Subject: | Re: HTTP headers and include() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295126@lists.php.net to get a copy of this message | ||
On Fri, Jul 10, 2009 at 1:21 AM, James Colannino<james@colannino.org> 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.
>
> James
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
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?
--Eddie