How can PHP be used to load a file from a different directory?

When loading a file from a different directory in PHP, you need to specify the full path to the file. This can be done using the `__DIR__` magic constant to get the current directory and then concatenating the desired file path to it. By using the correct file path, PHP can successfully load files from different directories.

$file_path = __DIR__ . '/path/to/file.txt';
$file_contents = file_get_contents($file_path);
echo $file_contents;