php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71486 Output handler flags for ob_end_clean and ob_end_flush
Submitted: 2016-01-30 15:56 UTC Modified: 2024-01-07 14:03 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: php at login dot hedim dot ch Assigned: girgias (profile)
Status: Closed Package: Output Control
PHP Version: 5.6.17 OS:
Private report: No CVE-ID: None
 [2016-01-30 15:56 UTC] php at login dot hedim dot ch
Description:
------------
According to http://php.net/manual/en/function.ob-end-clean.php: The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_CLEANABLE and PHP_OUTPUT_HANDLER_REMOVABLE flags. Otherwise ob_end_clean() will not work.

However, ob_end_clean() seems to work with only PHP_OUTPUT_HANDLER_REMOVABLE.

According to http://php.net/manual/en/function.ob-end-flush.php: The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_FLUSHABLE and PHP_OUTPUT_HANDLER_REMOVABLE flags. Otherwise ob_end_flush() will not work.

However, ob_end_flush() seems to work with only PHP_OUTPUT_HANDLER_REMOVABLE.

The test script below shows the problem with ob_end_clean(). To see the problem with ob_end_flush(), simply replace ob_end_clean() with ob_end_flush().


Test script:
---------------
ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE);
echo "1";
ob_end_clean();
echo "2";


Expected result:
----------------
A notice from ob_end_clean() and output "12"

Actual result:
--------------
Output "2"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-09 15:28 UTC] mike@php.net
-Type: Bug +Type: Documentation Problem
 [2016-03-09 15:28 UTC] mike@php.net
Actually, PHP_OUTPUT_HANDLER_CLEANABLE is only needed for `ob_clean()` because that's the only operation, that would leave the output handler alive instead of destroying and popping it off the stack.
 [2016-03-09 15:32 UTC] mike@php.net
See also #69404
 [2024-01-07 14:03 UTC] girgias@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: girgias
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 00:01:27 2024 UTC