What are some common pitfalls to avoid when working with file paths and directories in PHP?

One common pitfall to avoid when working with file paths and directories in PHP is using hardcoded paths that may not work across different environments. To solve this, it's recommended to use PHP's built-in functions like `__DIR__` or `dirname(__FILE__)` to dynamically generate paths based on the current file's location.

// Bad practice using hardcoded path
$file = '/path/to/file.txt';

// Good practice using dynamic path
$file = __DIR__ . '/file.txt';