Results 1 to 3 of 3

Thread: Problems with flushing output

  1. #1
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problems with flushing output

    This code flushes the output to the browser every 5 seconds as expected:

    Code:
    <?php
    
    for ($i=0; $i<5; $i++)
    {
        echo '<br>'.$i;
        ob_flush();
        flush();
    
        sleep(5);
    }
    
    ?>
    but some other scripts that use ob_flush(); flush();, and which used to work properly, now don't flush the output to the browser until the script has finished running.

    Does anyone know of a way to fix this?

  2. #2
    Join Date
    Feb 2004
    Posts
    4,877
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Take a look here for a long discussion on this topic:

    http://forums.redfoxuk.com/showthrea...ighlight=flush

    In short, I think the problem is that output doesn't start flushing until you have a decent amount of data flowing.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks. I've found the problem. I was calling ob_start() in an included file, and the script works as required when that's commented out. According to the PHP manual though, ob_flush() (which I was calling) should flush the buffer when ob_start() has been called:

    http://uk.php.net/manual/en/function.ob-flush.php

    The script also works as required when this line has been called at the start of the script:

    ini_set('output_buffering', 'On');

    which I thought did the same thing as ob_start().

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Flushing output buffer
    By steve_green in forum PHP
    Replies: 55
    Last Post: 21st February 2007, 05:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •