PHP flush and DIV - strange behavior

Discussion in 'PHP' started by tihan, Apr 11, 2010.

  1. #1
    hi,

    The flush() command is not working if I have opened DIV which contains another DIV.

    The script version 1 (below) display "e" then sleeping and displays the rest of the characters.
    If I close the first DIV, I get "eaa" before sleep (version 2).
    If I comment out the DIV, I get the same as version 2.

    Version 1:--------------------------------
    <?PHP ob_implicit_flush(true); ob_end_flush(); ?>
    e<div>a<div>a</div>
    <?PHP sleep(5); ?>
    <div>b</div>
    <?PHP sleep(5); ?>
    c</div>
    Version 2:------------------------------
    <?PHP ob_implicit_flush(true); ob_end_flush(); ?>
    e<div>a<div>a</div></div>
    <?PHP sleep(5); ?>
    <div>b</div>
    <?PHP sleep(5); ?>
    c</div>
    Version 3:------------------------------
    <?PHP ob_implicit_flush(true); ob_end_flush(); ?>
    e<div>a<div>a</div><!--</div>-->
    <?PHP sleep(5); ?>
    <div>b</div>
    <?PHP sleep(5); ?>
    c</div>
    -----------------------------

    Can you tell me the cause of this strange behavior and how can I fix it?
     
    tihan, Apr 11, 2010 IP
  2. webria

    webria Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Version 1:--------------------------------
    <?PHP
    ob_implicit_flush(true);
    ob_end_flush();
    ?>
    e
    <div>a<div>a</div>
    <?PHP sleep(1); ?>
    <div>b</div>
    <?PHP sleep(1); ?>
    c</div>
    Version 2:------------------------------
    <?PHP
    ob_implicit_flush(true);
    ob_end_flush();
    ?>
    e<div>a<div>a</div></div>
    <?PHP sleep(1); ?>
    <div>b</div>
    <?PHP sleep(1); ?>
    c</div>
    Version 3:------------------------------
    <?PHP ob_implicit_flush(true);
    ob_end_flush();
    ?>
    e<div>a<div>a</div><!--</div>-->
    <?PHP sleep(1); ?>
    <div>b</div>
    <?PHP sleep(1); ?>
    c</div>
     
    webria, Apr 12, 2010 IP