What are some best practices for handling file paths in PHP, especially when dealing with network resources?

When dealing with file paths in PHP, especially when accessing network resources, it is important to use the correct directory separators and handle any potential errors that may arise. One best practice is to use the `DIRECTORY_SEPARATOR` constant to ensure cross-platform compatibility when constructing file paths. Additionally, it is recommended to use functions like `realpath()` to resolve any symbolic links and ensure the path is valid.

// Example of handling file paths in PHP
$networkPath = '\\\\server\\share\\file.txt';
$absolutePath = realpath($networkPath);

if ($absolutePath) {
    echo "Absolute path: " . $absolutePath;
} else {
    echo "Invalid path or file does not exist.";
}