PHP flush() Function
❮ PHP Output Control Functions
Example
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!";
?>
Try it Yourself »
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
flush();
Technical Details
PHP Version: | 4+ |
---|
❮ PHP Output Control Functions
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.