What are the potential benefits of using output buffering in PHP for generating static HTML files through included templates?

Using output buffering in PHP can improve the performance of generating static HTML files through included templates by capturing all output and storing it in a buffer before sending it to the browser. This can reduce the number of server requests and improve load times by generating the HTML content in one go rather than piecemeal.

<?php
ob_start(); // Start output buffering

// Include template files
include 'header.php';
include 'content.php';
include 'footer.php';

// Get the buffered content
$html = ob_get_clean();

// Save the generated HTML to a static file
file_put_contents('static.html', $html);
?>