What are the best practices for organizing file paths in PHP includes?

When organizing file paths in PHP includes, it is important to establish a consistent and logical structure to ensure easy maintenance and readability. One common practice is to define base paths as constants and use them to construct file paths dynamically. Additionally, using directory separators like DIRECTORY_SEPARATOR constant can ensure cross-platform compatibility.

<?php
define('BASE_PATH', __DIR__);
define('INCLUDES_PATH', BASE_PATH . DIRECTORY_SEPARATOR . 'includes');

include(INCLUDES_PATH . DIRECTORY_SEPARATOR . 'header.php');
include(INCLUDES_PATH . DIRECTORY_SEPARATOR . 'footer.php');
?>