dongqun9403 2018-12-02 07:13
浏览 83

在ob_start中创建的file_put_contents延迟

I am caputuring the contents for a file with ob_start() the contents are generated through a loop and within that loop I have another ob_start() outputting to a second file.

Like this

ob_start()
for(loop=0;$loop<=1000;$loop++){

ob_start();
    ?>
    <p style="text-align:center"><?php echo $studentCounter.'/'.count($students);?></p>
    <?php
    file_put_contents('htmlpolling/'.$datePassed.$_SESSION['userCode'].'TTT'.$studentCounter.'.html', ob_get_clean());
}

    file_put_contents('htmlpolling/'.$_SESSION['userCode'].'.html', ob_get_clean());

The files create successfully, but the files which are created inside the loop don't appear until the loop as finished and the final file is written.

Any reason for this?

  • 写回答

1条回答 默认 最新

  • douxing5598 2018-12-02 08:24
    关注

    Issue was that there was a lot of retrieving from databases / storing in arrays before the file creation happened... once all of that time consuming bit was done, files were actually creating pretty much immediately which is why they APPEARED to only generate at the end.

    评论

报告相同问题?