php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44150 ob_start(): documentation for "output_callback" parameter innaccurate
Submitted: 2008-02-18 13:15 UTC Modified: 2008-11-07 12:03 UTC
From: robin_fernandes at uk dot ibm dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: robin_fernandes at uk dot ibm dot com
New email:
PHP Version: OS:

 

 [2008-02-18 13:15 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-07 12:03 UTC] vrana@php.net
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."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 16:01:31 2024 UTC