Show results while script is still executing

前端 未结 4 886
遇见更好的自我
遇见更好的自我 2020-11-28 06:16

Right now in order to see the results, I have to wait until the entire code is done executing. It hangs until it\'s complete and stays loading. Once it\'s finished it shows

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 06:49

    You can use output buffering like this:

    ob_start();
    
    echo('doing something...');
    
    // send to browser
    ob_flush();
    
    // ... do long running stuff
    echo('still going...');
    
    ob_flush();
    
    echo('done.');
    ob_end_flush(); 
    

提交回复
热议问题