What are common pitfalls to avoid when using relative file paths in PHP scripts, especially when working with external files like Excel documents?

Common pitfalls to avoid when using relative file paths in PHP scripts include not accounting for the script's current working directory, assuming a fixed directory structure, and not handling file path separators properly. To solve this, it's important to use the `__DIR__` magic constant to get the directory of the current script and then construct the file path relative to that.

// Get the directory of the current script
$dir = __DIR__;

// Construct the relative file path to the Excel document
$excelFilePath = $dir . '/path/to/excel/document.xlsx';

// Use $excelFilePath in your code to access the Excel document