I'm doing an online database dumping tool.
But when I output the data, PHP will wait until it can calculate the length it needs to dump, which may confuse the user about whether the API is working or not.
How can I send a response in chunks?
I tried adding:
header('Transfer-Encoding:chunked');
But Chrome browser couldn't open the page with it.
What do I need to do?
Thanks!
Answer: should encoding data before send it.
function chunk_encoding($chunk) {
printf("%x\r\n%s\r\n", strlen($chunk), $chunk);
flush();
ob_flush();
}