How can the dirname(__FILE__) function be used to obtain the path of the current file in PHP, and why is it recommended to include global PHP files with path constants?

To obtain the path of the current file in PHP, the `dirname(__FILE__)` function can be used. This function returns the directory name component of the path to the current file. It is recommended to include global PHP files with path constants to ensure that the included files are always referenced correctly, regardless of the current working directory.

<?php
define('ROOT_PATH', dirname(__FILE__));
include(ROOT_PATH . '/global.php');
?>