Something to watch look for when getting HEADER Warnings
| From: | John Manko | Date: | Sat, 19 Jul 2003 04:49:15 +0000 |
| Subject: | Something to watch look for when getting HEADER Warnings | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155868@lists.php.net to get a copy of this message | ||
Recently, I ran into a problem where I continually got a "Header already sent" message.
I took me a while to figure out because the file that was "included" only contained function definitions, or so I thought.
After the closing php tag, I had a new line with a single space on it. This space was, in turn, sent to the browser.
---- file.php begin (blah, not working) -----
<?php
function seomthing()
{ //do something
}
?>[enter]
[space]
---- file.php end ------
It wasn't until I removed the single space and any additional newlines that all worked fine.
Any non-null lines outside of the php tags will results in voiding all
rights to send any header or cache information, and this includes
space or newline characters.
Just an FYI.
---- file.php begin (cool, it works now) -----
<?php
function seomthing()
{ //do something
}
?>[no newline]
---- file.php end ------
Actually, you can have a newline after the clsoing php tab, but if you have a
non-null string following that (this includes newline characters), bad bad stuff can happen.