How can I determine the path of a PHP script on a website using a function?

To determine the path of a PHP script on a website, you can use the `$_SERVER['SCRIPT_FILENAME']` variable which contains the absolute path of the currently executing script. You can also use `$_SERVER['PHP_SELF']` to get the path of the current script relative to the document root.

// Getting the absolute path of the currently executing script
$absolute_path = $_SERVER['SCRIPT_FILENAME'];
echo "Absolute Path: " . $absolute_path;

// Getting the path of the current script relative to the document root
$relative_path = $_SERVER['PHP_SELF'];
echo "Relative Path: " . $relative_path;