What are best practices for handling absolute paths and URLs when including external scripts in PHP?

When including external scripts in PHP, it's important to handle absolute paths and URLs correctly to ensure that the scripts are loaded successfully. One best practice is to use the PHP `$_SERVER['DOCUMENT_ROOT']` variable to generate the absolute path to the script or file. This ensures that the path is always correct regardless of the server configuration.

<?php
$absolute_path = $_SERVER['DOCUMENT_ROOT'] . '/path/to/external/script.js';
echo '<script src="' . $absolute_path . '"></script>';
?>