PHP Warning! -.-

Status
Not open for further replies.

adamparkzer

On Extended Leave
Messages
3,745
Reaction score
81
Points
0
I recently found an error_log in my public_html folder that I haven't noticed. The entire log is of the same error over and over again:

[11-Jun-2009 23:23:21] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/adampark/public_html/index.php:1) in Unknown on line 0
Does anyone know what this even means?
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Some output was sent before you called the header() function. Check for any characters before or after <?php ?> tags. Errors also count as output so if you have an error before header() it will have an error at header() as well.
 

adamparkzer

On Extended Leave
Messages
3,745
Reaction score
81
Points
0
Thanks, Garrett, you were right. There was an error that wasn't showing up on my page for some reason, but now it is. The original error message is gone. Now I have a new one.

[12-Jun-2009 08:56:04] PHP Warning: ob_start() [<a href='ref.outcontrol'>ref.outcontrol</a>]: output handler 'ob_gzhandler' conflicts with 'zlib output compression' in /home/adampark/public_html/misc/header.php on line 1
So. Anybody wanna tell me what that means, then? lol
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Your site is using both zlib output compression and output buffering's compression handler. As you shouldn't compress output twice, this is a mistake. Look for the line that starts output buffering ("ob_start('ob_gzhandler');") and replace it with something like:
Code:
if (@ini_set('zlib.output_compression',TRUE) ||
    @ini_set('zlib.output_compression_level',2)) 
{
    ob_start();
} else {
    ob_start('ob_gzhandler');
}
 

adamparkzer

On Extended Leave
Messages
3,745
Reaction score
81
Points
0
Which is a more optimal form of compression? It appears from your code as if zlib should have higher priority than ob, but is there a drastic difference between the two?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Which is a more optimal form of compression?
They're basically the same when it comes to how much they'll compress data. ob_gzhandler uses the zlib extension. The differences are that zlib output compression lets you set the compression level (ob_gzhandler doesn't) and ob_gzhandler requires that you use output buffering. To me, ob_gzhandler is less desirable because if you turn on output buffering late or end output buffering, uncompressed data can be sent to the client. On the other hand, zlib output compression compresses all output while ob_gzhandler lets you pick which pages to compress. My personal preference is to use mod_deflate when I can.

It appears from your code as if zlib should have higher priority than ob, but is there a drastic difference between the two?
It's not so much that zlib output compression is given precedence as it is that configuration happens before PHP statement evaluation. When it comes time to turn on output buffering, the zlib output compression setting (along with the rest of the PHP configuration) has already been processed.
 

adamparkzer

On Extended Leave
Messages
3,745
Reaction score
81
Points
0
Sounds good, it seems like I should go with zlib then. Thanks for your help!
 
Status
Not open for further replies.
Top