In this article, you will learn how to get the currently buffered output of the server. The flush() function in PHP requests the server to send its currently buffered output to the browser. The server configuration may not always allow this to happen.
what is the syntax of the FLUSH() function in php?
flush();
examples of the FLUSH() function
Example 1. In this example, we output a string to the browser before the script has finished running.
<?php
// Some browsers will not display the content if it is too short
// We use str_pad() to make the output long enough
echo str_pad("Hello World!", 4096);
// Use flush() to send the string to the browser
flush();
// Display the rest of the content three seconds later
sleep(3);
echo "<br>";
echo "Hello World!";
?>