Edit report at https://bugs.php.net/bug.php?id=60468&edit=1
ID: 60468 Updated by: m...@php.net Reported by: vr...@php.net Summary: Output is not discarded when ob_start() callback returns "" -Status: Open +Status: Closed Type: Bug Package: Output Control Operating System: Windows PHP Version: 5.4.0RC2 -Assigned To: +Assigned To: mike Block user comment: N Private report: N New Comment: 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 http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-12-26 08:33:39] 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. ------------------------------------------------------------------------ [2011-12-08 08:26:27] vr...@php.net Description: ------------ 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"; exit; Expected result: ---------------- 2 2 b 0 Actual result: -------------- 2 4 4 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60468&edit=1