Realtime Output and Sleep

Discussion in 'PHP' started by m_maheshwariin, Jun 20, 2009.

  1. #1
    Hello,

    I am using sleep function for giving break to CPU,

    <?php

    // current time
    echo date('h:i:s') . "\n";
    ob_implicit_flush(true);

    // sleep for 10 seconds
    sleep(10);

    // wake up !
    echo date('h:i:s') . "\n";

    ob_implicit_flush(true);

    // sleep for 10 seconds
    sleep(10);

    // wake up !
    echo date('h:i:s') . "\n";

    ?>

    Mean it will work like realtime output, any suggestions?
     
    m_maheshwariin, Jun 20, 2009 IP
  2. amber.long83

    amber.long83 Active Member

    Messages:
    144
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #2
    you need to declare ob_implicit_flush at the top of the page and then after each echo you need to put ob_flush() statement and then sleep funtion.
     
    amber.long83, Jun 22, 2009 IP
  3. livedating

    livedating Active Member

    Messages:
    161
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    83