I'm hoping someone here can help me with a problem I'm having with php buffering. I've contacted Support but they don't understand why it's not working.
I have a script which takes some time so want to flush the output to my browser to inform me of the progress. Unfortunately I only see the final page of text after some time and do not see the output build up slowly.
I've gone back to basics and turned off all buffering but the output still appears all in one go. I have the following test script, at benchmarks.org.uk/flush3.php, (sorry I can't make this a link as I haven't made 5 posts yet!) which shows that buffering isn't being used and then attempts to output a line of text every second:
Code:
<html>
<body>
<?php
echo "In .htaccess we have : php_flag output_buffering Off";
echo "<br><br>This is confirmed by : ini_get('output_buffering') = ". ini_get('output_buffering');
echo "<br>ob_get_status() confirms buffering is off (it returns an empty array) : ob_get_status(true) = ";
print_r(ob_get_status(true));
for ($i=0;$i<5;$i++) {
echo "<br><br>Wait 1 second .............................................................................. ";
// try every flush possible and wait
ob_end_flush();
ob_flush();
flush();
sleep(1);
}
?>
<br><br>Done
</body>
</html>
I've used Wireshark to look at the packets being received by the browser and interestingly I see separate packets for the initial block of text and each following "Wait 1 second ..." message block. However they all arrive at the same time 5 seconds after requesting the page.
Does anyone have any ideas as to how I can resolve this?
Many thanks, Gary.