What functions can be used in PHP to force immediate output to the browser?
When working with PHP, sometimes you may need to force immediate output to the browser before the script has finished executing. This can be useful for scenarios like displaying progress updates or streaming data. To achieve this, you can use functions like `flush()` and `ob_flush()` to send any output that has been buffered so far to the browser instantly.
// Example code to force immediate output to the browser
ob_implicit_flush(true); // Enable implicit flushing
for ($i = 0; $i < 10; $i++) {
echo "Progress: $i/10<br>";
flush(); // Send output to the browser
sleep(1); // Simulate some processing time
}