How can defining a constant like 'ROOT' with the document root path improve file path management in PHP scripts?

Defining a constant like 'ROOT' with the document root path can improve file path management in PHP scripts by providing a centralized reference point for all file paths. This makes it easier to reference files and directories throughout the script without having to hardcode full paths each time. It also makes the code more portable and easier to maintain if the file structure changes.

define('ROOT', $_SERVER['DOCUMENT_ROOT']);
// Example usage:
include(ROOT . '/includes/header.php');