What are some common pitfalls when handling file paths in PHP, especially in a Windows environment?

One common pitfall when handling file paths in PHP, especially in a Windows environment, is using backslashes (\) instead of forward slashes (/) in file paths. To solve this issue, you can use the PHP built-in function `DIRECTORY_SEPARATOR` to dynamically generate the correct directory separator based on the operating system.

// Incorrect file path with backslashes
$filePath = 'C:\xampp\htdocs\example.txt';

// Correcting file path using DIRECTORY_SEPARATOR
$filePath = 'C:' . DIRECTORY_SEPARATOR . 'xampp' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'example.txt';