How can one determine the server address when including data from multiple servers using subdomains in PHP?

When including data from multiple servers using subdomains in PHP, one way to determine the server address is by using the $_SERVER['HTTP_HOST'] variable. This variable contains the host name of the server where the current script is executing. By parsing this variable, you can extract the subdomain and determine the server address.

$server_address = $_SERVER['HTTP_HOST'];
$subdomain = explode('.', $server_address)[0];
echo "Server Address: " . $server_address . "<br>";
echo "Subdomain: " . $subdomain;