Edit report at https://bugs.php.net/bug.php?id=60468&edit=1
ID: 60468 Comment by: me at ktamura dot com Reported by: vr...@php.net Summary: Output is not discarded when ob_start() callback returns "" Status: Open Type: Bug Package: Output Control Operating System: Windows PHP Version: 5.4.0RC2 Block user comment: N Private report: N New Comment: That's my proposed patch, although I am fairly new to PHP internals and not sure how robust it is. Previous Comments: ------------------------------------------------------------------------ [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