What are the potential pitfalls of using relative path references in PHP file operations?

Using relative path references in PHP file operations can lead to issues if the current working directory is not explicitly set or if the script is included from different locations. To avoid this, it's recommended to use absolute paths instead of relative paths to ensure that the files are accessed correctly regardless of the script's location.

// Use absolute path instead of relative path
$file = '/path/to/file.txt';

// Example of reading a file using absolute path
$data = file_get_contents($file);
echo $data;