What are the potential pitfalls of using flush() in PHP to output content in real-time?

Using flush() in PHP to output content in real-time can potentially cause performance issues, as it can increase server load and slow down the execution of your script. To avoid these pitfalls, consider using output buffering instead, which allows you to capture the output of your script and send it all at once when the script has finished executing.

// Start output buffering
ob_start();

// Output your content
echo "Hello, World!";

// Flush the output buffer and send the content to the browser
ob_end_flush();