Is it possible to generate static HTML pages using PHP scripts?

Yes, it is possible to generate static HTML pages using PHP scripts. One way to achieve this is by using PHP to dynamically generate the HTML content and then save it as a static HTML file on the server. This can be useful for caching dynamic content or creating static versions of dynamic pages for faster loading times.

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

// Your PHP code to generate HTML content goes here
$htmlContent = "<html><head><title>Static Page</title></head><body><h1>Hello, World!</h1></body></html>";

file_put_contents('static_page.html', $htmlContent); // Save HTML content to a static file

ob_end_clean(); // End output buffering and discard any output
?>