Calling ob_flush() and flush(), yet browser doesn't show any output until script finishes

后端 未结 12 2801
离开以前
离开以前 2020-12-07 00:55

Hi Please View Below Code :

\\n\";
for( $i = 0 ; $i < 10 ; $i++ )
{
    echo \"$i
\\n\";
12条回答
  •  攒了一身酷
    2020-12-07 01:03

    I am using laravel framework and buffering did not work but. This is solution :

    header( 'Content-type: text/html; charset=utf-8' );
    ob_start();
    
    ob_end_flush();
    ob_flush();
    flush();
    for($i = 1;$i<= 5;$i++){
        echo $i;
        ob_flush();
        flush();
    
        sleep(3);
    }
    

    You have to use first ob_end_flush();

提交回复
热议问题