What is the best method to retrieve the physical path of a PHP script?

To retrieve the physical path of a PHP script, you can use the `__FILE__` magic constant. This constant returns the full path and filename of the file in which it is used. By using `dirname(__FILE__)`, you can get the directory path of the current script.

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