What are the best practices for handling file paths and includes in PHP to avoid errors in different server environments?

When working with file paths and includes in PHP, it's important to use server-independent methods to avoid errors in different environments. One common approach is to use the `__DIR__` constant to get the absolute path of the current file and then construct paths relative to that. Additionally, using the `DIRECTORY_SEPARATOR` constant to handle directory separators dynamically can ensure compatibility across different operating systems.

// Define the base path using the __DIR__ constant
$basePath = __DIR__;

// Construct file paths using the base path and DIRECTORY_SEPARATOR
$includePath = $basePath . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'file.php';

// Include the file using the constructed path
include $includePath;