8

I noticed that the php flush(); doesn't work in Firefox 4 beta 7, as it works in 3.6.12.

I recently installed firefox 4 beta 7, and the contents are not being flush immediately when flush() is called. It used to work fine in 3.6.12. Is there any thing else that could provide me with the flushing functionality.

I've tried

flush();  
@ob_flush();

I also tried the following code at the top of the page.

@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
   ob_implicit_flush(1);

By the way, I use php on XAMPP/Apache. Thanks.


I found that setting content type to text/plain works, but it just outputs plain text and not html content.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
Ctroy
  • 577
  • 1
  • 10
  • 20
  • Perhaps the technique displayed in this question can help you on your quest http://stackoverflow.com/questions/4191349/php-buffer-why-r-n – nikc.org Nov 20 '10 at 07:32

2 Answers2

6

You're not seeing ghosts - I've experienced the same difference between FF3.6 and FF4.

Here's a work around: add an

echo str_repeat(" ", 1024);

before the output that needs to be flushed. You can put it for example in the <head>.

My theory is that FF4, like apparently IE and Safari, have a small buffer that needs to be filled before incremental rendering kicks in.

Erwin Wessels
  • 2,972
  • 1
  • 24
  • 17
1

flush will function identically server-side regardless of the browser. If the client is displaying things differently, there's not a lot you can do server-side to fix it.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • Is there something I can do on the client. As I mentioned earlier, it was working fine in firefox 3.6.12, but not in firefox 4 beta 7. – Ctroy Nov 20 '10 at 05:01
  • @Ctroy `flush` isn't your problem, what makes you think it is? – user229044 Nov 20 '10 at 05:04
  • I have this php page that I run locally which does some processing. I output some content to the page during processing which I want them to appear as soon I "echo" them in my page. – Ctroy Nov 20 '10 at 05:09
  • You used to be able to do an ajax call and flush the page and it would show in old Firefox. In the new Firefox this doesn't work, the page needs to be finished. This has something to do with those readystates. – Jelle De Loecker Feb 17 '11 at 13:34