How can defining a constant for the absolute path to the root directory improve the efficiency of PHP scripts?

Defining a constant for the absolute path to the root directory can improve the efficiency of PHP scripts by allowing you to easily reference files and directories without needing to calculate the path each time. This can reduce the likelihood of errors and make your code more maintainable. Additionally, using a constant for the root directory path can improve security by preventing directory traversal attacks.

define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT']);