Forcing output to screen not working

Discussion in 'PHP' started by ankit_frenz, Oct 11, 2009.

  1. #1
    I am using a code like below

    <?php
    for($i=0;$i<3;$i++)
    {
    	ob_start();
    	echo '<iframe src=http://google.com/ width=1000 height=800></iframe>';
    	ob_end_flush();
    	flush();
    	sleep(10);	
    }
    ?>
    PHP:
    Buts its giving the output at the end of the loop..instead i want the output during every loop..so i used ob stuff but still geting it in the end..

    any help will be highly appreciated.

    Thanks
     
    ankit_frenz, Oct 11, 2009 IP
  2. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #2
    Let's try to run a simpler program:
    <?php
    for($i=0;$i<3;$i++)
    {
        ob_start();
        echo 'It works...';
        ob_end_flush();
        flush();
        sleep(10); 
    }
    ?>
    Code (markup):
    Is this the behavior you want? Could you try this code, please?
     
    ForumJoiner, Oct 11, 2009 IP
  3. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    #3

    Yes thats the behaviour i need to implement...i dont understant whats the difference in the above two codes?
     
    ankit_frenz, Oct 11, 2009 IP
  4. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #4
    Quote from: http://www.php.net/sleep
    Please read the entire page above, as it might provide additional explanations.
     
    ForumJoiner, Oct 11, 2009 IP
    ankit_frenz likes this.
  5. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    #5
    Thanks for the help..
    I finally made it happen using Js instead :)

     
    ankit_frenz, Oct 11, 2009 IP