What are the potential pitfalls of using relative paths in PHP when accessing files?
Using relative paths in PHP when accessing files can lead to issues when the current working directory changes or when the script is included in another file with a different directory structure. To avoid these pitfalls, it's recommended to use absolute paths instead.
// Using absolute path to access a file
$file = '/var/www/html/data/file.txt';
$data = file_get_contents($file);
echo $data;