How can one create a continuous loop or stream using PHP, especially in the context of flush()?

When using PHP to create a continuous loop or stream, it is important to use the `flush()` function to send the output to the browser immediately instead of waiting for the script to finish executing. This allows for real-time updates to be displayed to the user. To create a continuous loop, you can use a `while` loop that continuously generates output and then flushes it to the browser.

<?php

// Set appropriate headers for streaming
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');

// Start an infinite loop
while (true) {
    // Generate some output
    $data = "Current time: " . date("H:i:s");

    // Send the output to the browser
    echo "data: $data\n\n";

    // Flush the output buffer
    flush();

    // Delay for 1 second
    sleep(1);
}
?>