I googled for this problem but there is no answer for it.
I want my PHP script to generate HTTP response in chunked( http://en.wikipedia.org/wiki/Chunked_transfer_en
Andriy F.'s solution worked for me. Here's a simplified version of his answer:
function dump_chunk($chunk)
{
echo $chunk;
flush();
ob_flush();
}
header('Content-Type: text/html; charset=UTF-8');
flush();
for ($i = 0; $i < 3; $i++) {
dump_chunk('Sending data chunk ' . ($i + 1) . ' of 1000
');
sleep(1);
}
Although I don't understand why the ob_flush() call is needed. If someone knows, please comment.