No announcement yet.

PHP BUffering

  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP BUffering

    I'm hoping someone here can help me with a problem I'm having with php buffering. I've contacted Support but they don't understand why it's not working.

    I have a script which takes some time so want to flush the output to my browser to inform me of the progress. Unfortunately I only see the final page of text after some time and do not see the output build up slowly.

    I've gone back to basics and turned off all buffering but the output still appears all in one go. I have the following test script, at, (sorry I can't make this a link as I haven't made 5 posts yet!) which shows that buffering isn't being used and then attempts to output a line of text every second:

    echo "In .htaccess we have : php_flag output_buffering Off";
    echo "<br><br>This is confirmed by : ini_get('output_buffering') = ". ini_get('output_buffering');
    echo "<br>ob_get_status() confirms buffering is off (it returns an empty array) : ob_get_status(true) = ";
    for ($i=0;$i<5;$i++) {
    	echo "<br><br>Wait 1 second .............................................................................. ";
    	// try every flush possible and wait
    I've used Wireshark to look at the packets being received by the browser and interestingly I see separate packets for the initial block of text and each following "Wait 1 second ..." message block. However they all arrive at the same time 5 seconds after requesting the page.

    Does anyone have any ideas as to how I can resolve this?

    Many thanks, Gary.

  • #2
    Hi Gary,

    I cannot figure out as to why your problem is occurring as I have never done something like this before. What I suggest you do is subscribe to the PHP Mailing List (PHP Mailing List) and ask in the PHP Mailing List as there are many experts that are subscribed to the mailing list, so you're likely to receive your answer that way .

    Hope this helps.


    • #3
      Hi Ben,

      Thanks for the suggestion. I'll take a look at the PHP Mailing List and see what I can find. At the moment I'm not convinced that it's php that's the problem here as the Wireshark output shows separate TCP messages. They just all come at once instead of every second. I'm currently investigating whether there's some sort of internal apache compression going on which is causing this problem.

      If there are any other website owners out there reading this and are willing to give it a go please could you try the script on your server and see if it works for you. That may or may not rule out a problem with my script. Many thanks for your help if you do try it out.



      • #4
        I've found the following website that allows you to test php code: . I've tried my script and ... it works as expected. Now I'm at a loss as to what I can do to resolve the problem .