Example
Output a string to the browser before the script has finished running:
html
<?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!";
?>
Definition and Usage
The flush() function requests the server to send its currently buffered output to the browser. The server configuration may not always allow this to happen.
Syntax
text
flush();
Technical Details
| PHP Version: | 4+ |
|---|