output to browser ?

Discussion in 'PHP' started by stats, Aug 24, 2009.

  1. #1
    How can i force my browser (or server) to output the result as soon as it becomes available ?

    such as ..

    for ($i=0; $i<1000; $i++) {
    // do a heavy operation here
    echo $result;
    }
    PHP:
    the problem is i always get chunks of results .. seems like it does some 10-20 (or any other number... randomly) passes trough the loop and then outputs a chunk of result, then does the next chunk, etc ..

    i want it to show me the output each and every time it goes trough the loop

    is it a browser setting i should change or is it a server setting i should change ?

    Thanks
     
    stats, Aug 24, 2009 IP
  2. Gray Fox

    Gray Fox Well-Known Member

    Messages:
    196
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Its server setting, try adding this to the beginning of your script
    
    ob_implicit_flush(1);
    ob_end_flush();
    
    PHP:
     
    Gray Fox, Aug 24, 2009 IP
  3. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    also:

    for ($i=0; $i<1000; $i++) {
    // do a heavy operation here
    echo $result;
    flush();
    }
    PHP:
     
    szalinski, Aug 24, 2009 IP