flush() 를 이용한 실시간 출력
<?php
header( 'Content-type: text/html; charset=euc-kr' );
// Set a valid header so browsers pick it up correctly.
header('Content-type: text/html; charset=utf-8');
// Explicitly disable caching so Varnish and other upstreams won't cache.
header("Cache-Control: no-cache, must-revalidate");
// Setting this header instructs Nginx to disable fastcgi_buffering and disable
// gzip for this request.
header('X-Accel-Buffering: no');
ob_start();
ob_end_clean();
ini_set("zlib.output_compression", 0); // off
ini_set("implicit_flush", 1); // on
//exit('test');
echo "
<html>
<head>
<title></title>
</head>
<body>
";
echo "프로그램 시작: ".date('Y-m-d H:i:s')."<p>";
for($i=1;$i<=5;$i++) {
echo "$i <br>";
echo str_pad("", 4096);
ob_flush();
flush();
sleep(1);
}
echo "프로그램 종료: ".date('Y-m-d H:i:s')."<p>";
echo "
</body>
</html>
";
?>