How can PHP be used to dynamically retrieve and include the domain name in a script that runs on multiple domains?

When developing a script that runs on multiple domains, it is essential to dynamically retrieve and include the domain name to ensure the script functions correctly on each domain. This can be achieved using the $_SERVER['HTTP_HOST'] variable in PHP, which contains the domain name of the current request. By retrieving this variable and incorporating it into the script, you can ensure that the script adapts to different domains seamlessly.

$domain = $_SERVER['HTTP_HOST'];
echo "Current domain: " . $domain;