PHP showing output of foreach to screen, for each item

前端 未结 4 1654
一整个雨季
一整个雨季 2021-01-13 15:05

One thing I have noticed with php, is that nothing is output to the screen until the script has stopped working. For the project I am working on I feed in a list of over 100

相关标签:
4条回答
  • 2021-01-13 15:21

    I use

    flush(); @ob_flush();
    

    after the output.

    0 讨论(0)
  • 2021-01-13 15:44

    flush() should do it, or you can look at all the output buffering functions

    0 讨论(0)
  • 2021-01-13 15:44

    Use the flush() command

    0 讨论(0)
  • 2021-01-13 15:47

    It may be better to store all script output in a buffer then flush the buffer when required.

    For example:

    <?php
    
    if (ob_get_level() == 0) ob_start();
    
    $test = Array('one','two','three','four');
    foreach ($test as $key=>$val)
    {
        echo $test;
        ob_flush();
        flush();
    }
    
    ob_end_flush();
    
    ?>
    

    Make sure you have mod_gzip disabled!

    0 讨论(0)
提交回复
热议问题