0

Possible Duplicate:
PHP buffer ob_flush() vs. flush()

What's the difference between flush() and ob_flush, and how should I use them properly?

Community
  • 1
  • 1
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
  • 2
    http://stackoverflow.com/questions/4191385/php-buffer-ob-flush-vs-flush – mario May 21 '11 at 14:12
  • 1
    @mario I don't really understand the accepted answer there, and it seems incomplete to me, maybe this sounds logical in it `flush sends data to ob, ob sends data to browser - may not be accurate but that's the idea) will be wrapped up and sent to the client` but this sounds like I need to use both of them, but they work alone too so I'm confused – Adam Halasz May 21 '11 at 14:14
  • 1
    @CIRK The accepted answer is not that great, but the highest-voted one is fine. – phihag May 21 '11 at 14:17
  • @phihag Yes that answer is not bad, but doesn't really tells me how should I use it properly, `Anyway, use both.` use both and how? flush() before ob flush or vice versa? should I use ob_end_flush() etc..? :S – Adam Halasz May 21 '11 at 14:25
  • 1
    well ok then I will ask these on marios answer on that question :P – Adam Halasz May 21 '11 at 14:27
  • 3
    `ob_flush()` is a high-level flush. It flushes high-level buffers and puts all content in the low-level, internal buffers ready to send. Do that first. `flush()` is a low-level flush, instructing PHP to flush its internal, low-level buffers. Below that still, there will be socket-layer buffers; below that, there are network-layer buffers. And, at the lowest level, the queue of electrons going down the data cable. – Lightness Races in Orbit May 21 '11 at 14:28
  • lol @Tomalak Geret'kal nice answer :)) why didn't you posted it? So I need to use both because flushing two levels is better than one? – Adam Halasz May 21 '11 at 14:31
  • 1
    @CIRK: The question is closed, so I cannot. I may post it on the other question. And, yes, usually if you want to be as sure as possible that your data is going straight to the browser then you want to flush on both layers; recall, though, that you don't have any control over the lowest level of buffering (sockets, electrons, caching on the user side...) – Lightness Races in Orbit May 21 '11 at 14:37
  • Duplicate of http://stackoverflow.com/questions/4191385/php-buffer-ob-flush-vs-flush – Bob Fanger May 21 '11 at 14:22

0 Answers0