I thought flush(); would work, at least from what Google/Stackoverflow tell me, but on my Windows WAMP (Windows, Apache, MySQL, PHP) system it doesn’t work.
Is there some PHP setting I have to set to make flush() work?
Here’s my code:
<?php
echo "Fun";
flush();
sleep(5);
echo "<br>Mo";
?>
The code just outputs all together when the script is done executing (after 5 seconds).. I don’t want this, I want ‘Fun’ to show up right away, and then after 5 seconds ‘Mo’.
I’ve tried other combinations of flush like ob_end_flush(); or ob_implicit_flush(true); but nothing is working. Any ideas?
The script works fine from CLI, displaying “Fun”, waiting 5 secs before displaying “<br>Mo”.
For a browser the results might be a bit different because:
To work around 1) use text/plain content type for your test; 2) needs newlines, so do an
echo "Fun\n";andecho "<br>Mo\n";Of course you wont be using text/plain for real HTML data.