Bluehost.com Web Hosting $6.95

PHP - Better to echo the HTML headers?

This is a discussion on PHP - Better to echo the HTML headers? within the Windows Web Servers forums, part of the Web Server and Related Forums category; When starting sessions in PHP, if I send raw HTML headers before invoking session_start() I get the following warnings. Warning: ...


Go Back   Usenet Forums > Web Server and Related Forums > Windows Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-02-2004
Kenneth Doyle
 
Posts: n/a
Default PHP - Better to echo the HTML headers?

When starting sessions in PHP, if I send raw HTML headers before invoking
session_start() I get the following warnings.

Warning: session_start(): Cannot send session cookie - headers already sent
by ... on line 55

Warning: session_start(): Cannot send session cache limiter - headers
already sent ... on line 55

However, if I first invoke session_start() before sending any HTML, the
warnings aren't raised. I'm assuming that I can fiddle with php.ini to
supress the warnings, but I'm wondering if it's always better (discounting
the "double markup") to ehco the HTML headers in the same PHP block after
the session_start() function. Maybe there are other fuctions besides
session_start() that will throw warnings if the HTML headers are already
set when they are invoked?
  #2 (permalink)  
Old 10-03-2004
David Dorward
 
Posts: n/a
Default Re: PHP - Better to echo the HTML headers?

Kenneth Doyle wrote:

> When starting sessions in PHP, if I send raw HTML headers before invoking
> session_start()


> However, if I first invoke session_start() before sending any HTML, the


You sound confused. There are two things to think about here:

* The HTTP headers
* The HTML document which will include a <head> element

The <head> element has nothing to do with the HTTP headers.

HTTP headers must be sent before the HTML document. The PHP session_start()
function, among other things, sends a number of HTTP headers and thus must
be called before any of the HTML document is sent.

If this doesn't clear things up, you might want to rephrase your question
(and use correct terminology).


--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
  #3 (permalink)  
Old 10-03-2004
Kenneth Doyle
 
Posts: n/a
Default Re: PHP - Better to echo the HTML headers?

David Dorward <dorward@yahoo.com> wrote in
news:cjnek7$ocg$2$8302bc10@news.demon.co.uk:

> Kenneth Doyle wrote:
>
>> When starting sessions in PHP, if I send raw HTML headers before
>> invoking session_start()

>
>> However, if I first invoke session_start() before sending any HTML,
>> the

>
> You sound confused. There are two things to think about here:


Yes, I was confused. What I meant by "raw HTML headers" was "any HTML code
at all".

> * The HTTP headers
> * The HTML document which will include a <head> element


....

> ... The PHP
> session_start() function ... must be called before any of the HTML

document is sent.


> If this doesn't clear things up, you might want to rephrase your
> question (and use correct terminology).


No, it's clearer now; thanks. I have to keep reminding myself that this is
ISAPI, not CGI.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:23 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0