How can output buffering be used to address the issue of including a file with mixed PHP and text content?

When including a file with mixed PHP and text content, the issue arises when the PHP code is executed immediately upon inclusion, leading to unexpected output. To address this, output buffering can be used to capture the output of the included file before it is sent to the browser, allowing for proper processing and control over the content.

<?php
ob_start();
include 'mixed_content_file.php';
$output = ob_get_clean();
echo $output;
?>