How can one ensure that the extracted body part of an HTML file is properly formatted and structured when included in PHP?

When including an extracted body part of an HTML file in PHP, it is important to ensure that the content remains properly formatted and structured. One way to achieve this is by using PHP's output buffering functions to capture the HTML content and then echo it out within the PHP file. This way, the HTML content will be rendered correctly within the PHP environment.

<?php
ob_start();
include 'extracted_body_part.html';
$body_content = ob_get_clean();
echo $body_content;
?>