|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-28 09:51 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
Description: ------------ During script termination, PHP's explicit output buffer flush should wait until all variables have gone -completely- out of scope. Using an instantiated object that manages buffers, the data has already been flushed before __destruct() is called, which prevents the script from properly finalizing data collection and flushing the output normally. This is not the appropriate behavior. Reproduce code: --------------- <?php error_reporting(E_ALL); class Example { function __construct() { ob_start(); echo 'This should be displayed last.'."\n"; } function __destruct() { $buffered_data = ob_get_contents(); ob_end_clean(); echo 'This should be displayed first.'."\n"; echo 'Buffered data: '. $buffered_data; } } $obj = new Example; ?> Expected result: ---------------- This should be displayed first. Buffered data: This should be displayed last. Actual result: -------------- This should be displayed last. Notice: ob_end_clean(): failed to delete buffer. No buffer to delete. in /--snip--/test.php on line 17 This should be displayed first. Buffered data: