|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60468 Output is not discarded when ob_start() callback returns ""
Submitted: 2011-12-08 08:26 UTC Modified: 2012-01-17 12:23 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: Assigned: mike (profile)
Status: Closed Package: Output Control
PHP Version: 5.4.0RC2 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2011-12-08 08:26 UTC]
If ob_start() callback returns an empty string then nothing should be printed. This is the current behavior in PHP 5.3. Behavior in PHP 5.4 is different - if a callback returns an empty string then the result is same as if it wouldn't be called at all - next call is prepended by last call value.

So there is no way for callback how to discard the output.

Test script:
ob_start(function ($s) {
	fwrite(STDERR, strlen($s) . "\n");
	if ($s == "b\n") {
		return $s;
	return "";
}, 2);
echo "a\n";
echo "b\n";

Expected result:

Actual result:


handle-empty-string (last revision 2011-12-26 08:32 UTC by me at ktamura dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-26 08:33 UTC] me at ktamura dot com
That's my proposed patch, although I am fairly new to PHP internals and not sure 
how robust it is.
 [2012-01-17 12:23 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2012-01-17 12:23 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 08 11:03:42 2023 UTC