How can the use of $_SERVER['DOCUMENT_ROOT'] in PHP be problematic in certain server configurations?

Using $_SERVER['DOCUMENT_ROOT'] in PHP can be problematic in certain server configurations because it relies on the server configuration to correctly identify the document root directory. If the server is configured differently, the value returned by $_SERVER['DOCUMENT_ROOT'] may not be accurate, leading to issues with file path resolution. To solve this issue, it is recommended to define a constant in your PHP script that explicitly sets the document root path.

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