Re: empty lines cause http headers?
| From: | mnc at stoic dot net | Date: | Mon, 18 Mar 2002 05:21:05 +0000 |
| Subject: | Re: empty lines cause http headers? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88888@lists.php.net to get a copy of this message | ||
On Mon, 18 Mar 2002, Michael Zornek wrote:
> The problem is that PHP seems to be sending the HTTP headers when it
> encounters the first blank line in the code (which I do use to help separate
> the code a bit).
>
> Am I right in this assumption .. and then the big Q.. how do I do PHP
> calculations and then specify a session without sending premature headers by
> accident?
Just make sure the blank lines are <? inside php tags ?>
If they're out in the raw HTML area, the headers will get packaged up and
the content output buffer collection will begin.
- - - - - - bad - - - - - -
<?
header('X-Site-Type: Fabulous');
print 'That blank line gave me just the breathing room I needed.';
?>
- - - - - - good - - - - - -
<?
header('X-Site-Type: Fabulous');
print 'So did this one, but it won't stop my header from working.';
?>
- - - - - - - - - - - -
miguel