From:             mpn at illearth dot net
Operating system: Win NT(2K)
PHP version:      4.3.9
PHP Bug Type:     Output Control
Bug description:  headers_sent() reporting incorrect value

Description:
------------
When checking the value of headers_sent(), function is returning FALSE
even though headers have clearly been sent.

Returned result does not change when output buffering is commented out or
where output buffering is started (i.e before sending headers or after ).

I crammed the test code into 19 lines, so please excuse the formatting.

["SERVER_SOFTWARE"]=>  string(31) "Apache/2.0.49 (Win32) PHP/4.3.9" using
sapi



Reproduce code:
---------------
<?php
ob_clean();
if ( stristr( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) ) { ob_start(
'compressOutput' ); } else { ob_start(); }
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', FALSE );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Pragma: no-cache' );
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>' . "\n\n";
echo '<html><head>' . "\n";echo '<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1" />' . "\n";echo '<meta
http-equiv="content-language"  content="en-GB" />' . "\n";
echo '</head><body>headers_sent() Returned Value Is: ' . "\n"; var_dump(
headers_sent() ); echo '</body></html>' . "\n";
ob_end_flush();
function compressOutput( $str ) {
    $_output = gzencode( $str );
    if ( (bool)FALSE === $_output ) { return $str; }
    header( 'Content-Encoding: gzip' );
    return $_output;
} // End Function compressOutput
?>

Expected result:
----------------
var_dump( headers_sent() ); = (bool)true

Actual result:
--------------
var_dump( headers_sent() ); = (bool)false

-- 
Edit bug report at http://bugs.php.net/?id=30264&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30264&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30264&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30264&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30264&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30264&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30264&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30264&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30264&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30264&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30264&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30264&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30264&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30264&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30264&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30264&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30264&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30264&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30264&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30264&r=mysqlcfg

Reply via email to