How can the current directory be output in PHP when working with files?

To output the current directory in PHP when working with files, you can use the `getcwd()` function, which returns the current working directory. This function can be helpful when you need to reference files or directories relative to the current location in your PHP script.

$currentDirectory = getcwd();
echo "Current directory: " . $currentDirectory;