What are some common pitfalls when dealing with file paths in PHP on different operating systems?

When dealing with file paths in PHP on different operating systems, a common pitfall is using hardcoded paths that may not be valid on all systems. To solve this issue, it's recommended to use PHP's built-in `DIRECTORY_SEPARATOR` constant and `realpath()` function to ensure the path is correct across different platforms.

// Define the base path using DIRECTORY_SEPARATOR
$basePath = __DIR__ . DIRECTORY_SEPARATOR . 'files';

// Construct the file path using realpath()
$filePath = realpath($basePath . DIRECTORY_SEPARATOR . 'example.txt');

// Use the file path in your code
echo $filePath;