How can PHP beginners effectively utilize the include function to output the contents of a file without displaying PHP commands?

When using the include function in PHP to output the contents of a file, beginners may inadvertently display PHP commands along with the desired content. To prevent this, beginners can utilize the ob_start() and ob_get_clean() functions to capture the output of the included file without displaying any PHP commands.

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