How can the magic constant __FILE__ be used to determine the directory of a specific file in PHP?

The magic constant __FILE__ in PHP represents the full path and filename of the current file. By using this constant in combination with other PHP functions, we can determine the directory of a specific file. One way to achieve this is by using the dirname() function to extract the directory path from the __FILE__ constant.

$directory = dirname(__FILE__);
echo $directory;