How can the use of $_SERVER['DOCUMENT_ROOT'] be optimized for file inclusion in PHP scripts?

Using $_SERVER['DOCUMENT_ROOT'] can be optimized for file inclusion in PHP scripts by storing the document root path in a variable at the beginning of the script. This way, you only need to access $_SERVER['DOCUMENT_ROOT'] once and then use the variable throughout the script for file inclusions.

<?php
$document_root = $_SERVER['DOCUMENT_ROOT'];

include($document_root . '/path/to/file.php');
include($document_root . '/path/to/another_file.php');
?>