|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60175 ob_implicit_flush is brain-damaged or something I dunno
Submitted: 2011-10-30 15:32 UTC Modified: 2011-11-02 09:12 UTC
From: artificialmagic at hotmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.3.8 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 - 15 = ?
Subscribe to this entry?

 [2011-10-30 15:32 UTC] artificialmagic at hotmail dot com
I'm trying to use output buffering in CLI to log output as it's echoed. But ob_implicit_flush is a bunch of feral cock. Look at this bullpoop:

Test script:
ob_start(function ($s) {
	return "[" . strlen($s) . "]";
for (;;) echo '.';

Expected result:
[1][1][1][1][1][1][1][1]... ad infinitum

Actual result:
Nothing is ever displayed.

Memory usage goes up and up until the script crashes. PHP would be quite happy apparently to consume additional universes if it could get more memory out of it to fill with "."'s.

The documentation says "Implicit flushing will result in a flush operation after every output call". Well maybe it does do that, I don't know, but whatever it's doing it doesn't generate the result implied by the documentation. It's a God-damn lie in spirit. I feel betrayed.

Try to specify 1 as the buffer size to ob_start as a workaround. Just TRY IT, and watch the sheer audacity of the thing as it calmly prints out [4096][4096][4096][4096][4096][4096].... Because apparently some herp-derp let's-just-add-random-quirks-for-laughs moron at PHP bollocksing years ago decided 1 = 4 kB. That's a nice idea isn't it. That's real fucking neato.

The best I can get apparently is to specify a buffer size of 2 to ob_start, which will cause [2][2][2][2][2][2][2][2][2][2]....

But that's no fucking good because individual characters won't echo until another one happens to come along. THIS IS A PROGRAMMING LANGUAGE NOT THE BUS STOP.

If you can't make ob_implicit_flush do what it blatantly claims it will do could you at least make -1 to ob_start a synonym for a real 1 so this can be made to work. Thanks very much. Meanwhile I'll just go and drown myself in a see of hideous synonym functions ("echo2($boop);", "var_dump2($blah);"). Don't worry about me, I completely enjoy that.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-30 17:21 UTC] artificialmagic at hotmail dot com
By the way I already tried using a stream filter instead of output buffering, adding it with:

stream_filter_append(STDOUT, 'BlahFilter');


stream_filter_append(fopen('php://output', 'wb'), 'BlahFilter');

But it had absolutely no effect. I'd like to say I'm surprised, or even vaguely confused, but sane behavior from PHP is rarer than a ST:TOS redshirt that survives their first away mission.
 [2011-11-02 09:12 UTC]
-Status: Open +Status: Bogus
 [2011-11-02 09:12 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

"output call" means system output call.

chunk_size==1 has a special meaning for ob_start, because you can specify 
output_buffer=on in php.ini.

STDOUT and php://stdout are just stream wrappers.

Your language is funny though.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 17:01:31 2024 UTC