How to go emptying PHP buffer while running

Asked

Viewed 330 times

2

I’ve seen somewhere a code that configures PHP to go emptying the Buffer (print on screen) while running script without the need to wait all the execution for something to be displayed.

Has anyone seen or knows what that command is?

1 answer

3


The method you seek is the ob_flush.

It’s also possible, rather than letting the buffer from time to time, to output the buffer whenever a echo with:

ob_implicit_flush(true);

Finally, you can set up directly on php.ini:

implicit_flush = Off
  • Exactly, I already knew and use constantly the ob_flush to put the contents of the buffer in variables, but I did not care that it also downloaded the buffer on the screen... : D Agora esse do ob_implicit_flush was awesome, didn’t know, very good.

  • You can configure the directive implicit_flush in the php.ini, and so do not need to set this always :)

  • Thanks for this information, it might be useful for people who need it (add the directive in the reply), but I need this functionality only for a specific function so it’s best to just call the function in the file.

  • @Kaduamaral Feito. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.