What are the best practices for structuring include files in PHP to avoid complications with directory paths?

When structuring include files in PHP, it's important to use relative paths to avoid complications when moving files to different directories. One common practice is to define a constant for the base directory and then use this constant in all include paths. This way, you can easily update the base directory if needed without having to change all include paths in your code.

<?php
define('BASE_DIR', __DIR__);

include BASE_DIR . '/includes/header.php';
include BASE_DIR . '/includes/footer.php';
?>