#28489 [Opn->Bgs]: Destructor sending headers?
| From: | derick@php.net | Date: | Sat, 22 May 2004 15:39:28 +0000 |
| Subject: | #28489 [Opn->Bgs]: Destructor sending headers? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59887@lists.php.net to get a copy of this message | ||
ID: 28489
Updated by: derick@php.net
Reported By: bonebreaker at free dot fr
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 5.0.0RC2
New Comment:
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
Headers are sent before dtors are run, that's expected (and normal)
behavior.
Previous Comments:
------------------------------------------------------------------------
[2004-05-22 16:24:15] bonebreaker at free dot fr
Description:
------------
__destruct() appears to be automatically sending headers before it's
ran.
Output buffering can't prevent this behaviour.
Tested on Windows XP, Apache 2.0.48
Reproduce code:
---------------
class Test {
function __construct()
{
$this->_string = '__construct()<br />';
}
function __destruct()
{
if (headers_sent($file, $line)) {
$this->_string .= 'Headers sent in ' . $file . ' on line '
. $line;
} else {
$this->_string .= '__destruct()';
}
print $this->_string;
}
}
$test = new Test();
Expected result:
----------------
__construct()
__destruct()
Actual result:
--------------
__construct()
Headers sent in on line 0
Though headers_sent() returns true, $file and $line still have default
values.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28489&edit=1