#44150 [Opn->Csd]: ob_start(): documentation for "output_callback" parameter innaccurate

From: Date: Fri, 07 Nov 2008 12:03:51 +0000
Subject: #44150 [Opn->Csd]: ob_start(): documentation for "output_callback" parameter innaccurate
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1434@lists.php.net to get a copy of this message
ID: 44150 Updated by: vrana@php.net Reported By: robin_fernandes at uk dot ibm dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: * PHP Version: Irrelevant New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. "The function will be called when the output buffer is flushed (sent) or cleaned (with ob_flush(), ob_clean() or similar function) or when the output buffer is flushed to the browser at the end of the request." Previous Comments: ------------------------------------------------------------------------ [2008-02-18 13:15:45] robin_fernandes at uk dot ibm dot com Description: ------------ The description of the "output_callback" parameter in the doc for ob_start() states that: "The function will be called when ob_end_flush() is called, or when the output buffer is flushed to the browser at the end of the request." The testcase below shows 3 undocumented cases where the callback is invoked: - when the output buffer is flushed with ob_flush() - when the output buffer is cleaned with ob_clean() - when the output buffer is cleaned with ob_end_clean(). This could be indicated by adapting the description as follows: "The callback function will be invoked when the output buffer is flushed explicitly (using ob_flush() or ob_end_flush()), when it is flushed implicitly at the end of the request, or when it is cleaned (using ob_clean() or ob_end_clean()). In the case where the buffer is cleaned, the callback's return value is ignored." Reproduce code: --------------- <?php $a = ''; function output_handler($buffer, $mode) { global $a; static $i=0; $i++; $a .= "\n-->$i: In output_handler($buffer, $mode)"; return "Hello"; } echo "About to start buffer.\n"; ob_start('output_handler'); echo "About to call 'ob_flush()'"; ob_flush(); echo "About to call 'ob_clean()'"; ob_clean(); echo "About to call 'ob_end_clean()'"; ob_end_clean(); echo "\nEnded buffer.\n"; echo "\n\nShow when the callback was really invoked:"; echo $a; ?> Expected result: ---------------- N/A Actual result: -------------- About to start buffer. Hello Ended buffer. Show when the callback was really invoked: -->1: In output_handler(About to call 'ob_flush()', 3) -->2: In output_handler(About to call 'ob_clean()', 2) -->3: In output_handler(About to call 'ob_end_clean()', 4) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44150&edit=1

« previous php.doc.bugs (#1434) next »