What are some best practices for structuring PHP code to avoid issues with including files from different directories?

When including files from different directories in PHP, it's important to use absolute paths to avoid issues with relative paths. One way to do this is by defining a base path constant in your main configuration file and using it to construct absolute paths when including files.

// Define base path constant in your main configuration file
define('BASE_PATH', __DIR__);

// Include files using absolute paths
include(BASE_PATH . '/path/to/file.php');