Is it possible to combine HTML content with a file download in PHP?
Yes, it is possible to combine HTML content with a file download in PHP by using output buffering. You can first output the HTML content, then use the `header()` function to set the appropriate headers for downloading a file, and finally output the file content.
<?php
// Start output buffering
ob_start();
// Output HTML content
echo "<html><body><h1>Hello World!</h1></body></html>";
// Set headers for file download
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"example.txt\"");
// Output file content
echo "This is the content of the file.";
// Flush output buffer
ob_end_flush();
?>