What is the best practice for including files in PHP to avoid duplicate header and body tags?

When including files in PHP, it's important to avoid duplicating header and body tags to prevent rendering issues. One way to solve this is by using PHP's include_once or require_once functions to ensure that a file is only included once in the script. This way, you can separate your header, body, and footer into separate files and include them in your main PHP file without worrying about duplicate tags.

<?php
include_once 'header.php';
include_once 'body.php';
include_once 'footer.php';
?>