#32406 [Opn]: PHP claims that headers are set when __destruct is called
| From: | derick@php.net | Date: | Tue, 22 Mar 2005 08:13:57 +0000 |
| Subject: | #32406 [Opn]: PHP claims that headers are set when __destruct is called | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969367055@lists.php.net to get a copy of this message | ||
ID: 32406
Updated by: derick@php.net
Reported By: webmaster at benliles dot com
Status: Open
-Bug Type: Zend Engine 2 problem
+Bug Type: Documentation problem
Operating System: *
PHP Version: 5.*
New Comment:
Marcus is right, this is expected and should be documented if it's not
already
Previous Comments:
------------------------------------------------------------------------
[2005-03-22 01:04:07] webmaster at benliles dot com
We are output buffering and in the destructor for a page class, we dump
the output buffer. There is nothing in the documentation to indicate
when headers would be sent before this point.
Also, the headers_sent function is not reporting correct information.
The file name is blank and line number is zero.
------------------------------------------------------------------------
[2005-03-22 00:19:27] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
__destruct is called during script shut down - that is everything has
already been sent. Add a '$test = NULL;' in front of the '?>' and
you'll see.
------------------------------------------------------------------------
[2005-03-22 00:16:31] webmaster at benliles dot com
Description:
------------
It appears that PHP has a flag set for headers already being sent when
__destruct() is called despite the fact that nothing is being sent
before that. This has been seen in PHP 5.0.2 and PHP 5.0.3 with two
different operating systems. This is not documented as claimed in an
earlier bug report.
Reproduce code:
---------------
<?
class letsTestThis {
public function __destruct() {
if (!headers_sent($file,$line)) {
header("Content-type: text/xml");
echo "Some cool XML!";
} else {
echo "Headers already sent in file: ".$file."<BR>\nOn Line:
".$line."<BR>\n";
}
}
}
$test = new letsTestThis();
?>
Expected result:
----------------
Some cool XML
Actual result:
--------------
Headers already sent in file:
On Line: 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32406&edit=1