RE: Something to watch look for when getting HEADER Warnings
| From: | Ow Mun Heng | Date: | Mon, 21 Jul 2003 02:48:22 +0000 |
| Subject: | RE: Something to watch look for when getting HEADER Warnings | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-156009@lists.php.net to get a copy of this message | ||
Been There..
Was a REAL pain to figure that out one..
Have a look through PhpMyAdmin's (source) scripts, I see there's a bash
shell code that actually searches through some of it's php files for
sanitation for the exact same purpose. (Haven't played with it yet though)
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia
DID : 03-7870 5168
-----Original Message-----
From: John Manko [mailto:xerid@adelphia.net]
Sent: Saturday, July 19, 2003 12:49 PM
Cc: php-general@lists.php.net
Subject: Something to watch look for when getting HEADER Warnings
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.