FLUSH() is not actually flushing!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
schworak
Forum Newbie
Posts: 3
Joined: Wed Apr 25, 2012 2:33 pm

FLUSH() is not actually flushing!!!

Post by schworak »

I have read a bunch about FLUSH and potential issues and I am experiencing one such issue that I can't seem to figure out.

I can flush() or ob_end_flush() and still, nothing goes to the browser! :banghead:

I even push out 4k worth of SPACES wrapped inside of <!-- --> marks to make sure a lot of data is being pushed but still, nothing goes out to the browser.

I am running Linux / Apache2 and PHP 5.3.5.

I am guessing (only guessing) that PHP is sending the data but perhaps Apache is keeping the data buffered itself but I have no idea how to test this or how to change it if that is the case. If there is a way to turn off all Apache buffering in my web site's config file, that would be my preferred way to do it or in the .htaccess if needed. Then I only have to worry about PHP buffering.

Any help would be appreciated.

Thanks!
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: FLUSH() is not actually flushing!!!

Post by twinedev »

If you are getting absolutely nothing from the server, have you checked to see if you are possibly getting an error and the settings are set to not show you any error informatuon. Some system.

-Greg
schworak
Forum Newbie
Posts: 3
Joined: Wed Apr 25, 2012 2:33 pm

Re: FLUSH() is not actually flushing!!!

Post by schworak »

I am not sure what you mean about the error. My page is not malfunctioning in any way except that the data isn't sent out to the browser when I turn off the output buffer or call the flush function.

But perhaps I have not been totally clear either. I don't get any output when I flush or ob_end_flush but when the page actually finishes executing, I finally get all of the output that I had been trying to send to the browser the entire way along. This page in particular is a very long running page and I need to send progress information every couple minutes. That progress information is not making it to the browser until the entire job is done.

Hope that clears up the issue.
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: FLUSH() is not actually flushing!!!

Post by x_mutatis_mutandis_x »

Even if you flush the buffer, output is not sent to the browser until the script finishes execution. Consider storing the state/progress in a cache (or user session), and use AJAX request to read it and show the status/progress to the user.
Post Reply