interesting behavior of ob_end_flush() in __destruct()
| From: | aRZed | Date: | Fri, 24 Sep 2004 19:19:35 +0000 |
| Subject: | interesting behavior of ob_end_flush() in __destruct() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-197798@lists.php.net to get a copy of this message | ||
I discovered an interesting behavior, when ob_end_flush() or ob_end_clean() is used in a destructor of an object.
I don't think it is actually a bug, so i decided to post it here.
<?php
class foo
{
public function __construct()
{
ob_start();
}
public function __desctruct()
{
ob_end_flush();
}} $f = new foo(); // end of file ?> this ends in an error: Notice: ob_end_flush(): failed to delete buffer. No buffer to delete. in ... but this functions very well. <?php // with the same class foo $f = new foo(); unset($f); // end of file ?> it seems that php first ends output buffering and then calls then destrcuts the objects. so the output buffering is still ended when the destructor is calles. one has to unset the object to reverse that order manually. aRZed