What are the best practices for defining file paths in PHP when the files are located outside the htdocs directory?

When files are located outside the htdocs directory in PHP, it is important to define file paths correctly to access them. One common approach is to use the `$_SERVER['DOCUMENT_ROOT']` variable to get the absolute path to the htdocs directory and then concatenate it with the relative path to the desired file.

// Define the absolute path to the htdocs directory
$rootPath = $_SERVER['DOCUMENT_ROOT'];

// Define the relative path to the file outside htdocs directory
$filePath = $rootPath . '/path/to/file';

// Use the $filePath variable to access the file
include $filePath;