first of all, domains do not point at 'index.html', they point at an IP address, it is then up to the configuration of the web server ie:(apache, IIS, lighthttp) to determine how to handle the domain request by serving the contents of a 'document root' folder specified in the server configuration.
a virtual host block in the apache conf would look something like this
Code:
<VirtualHost x.x.x.x:80>
DocumentRoot /home/user/content/www
ServerName x.gotdns.com
<Directory "/home/user/content/www">
allow from all
allowoverride all
Options +Indexes
</Directory>
</VirtualHost>
where
Code:
/home/user/content/www
is a folder that acts as the root of your web-site's tree structure.
As for whether or not it's permissible to have multiple domains share the same document root, this is not only possible but such commonplace as there are ways of doing this with 'alias' directives, and there php scripts (such as Drupal) that are even coded to be able to take advantage of it to make one code base behave like a theoretically infinite number of discrete sites based on domain/subdomain.
example (extract from above)
Code:
ServerName x.gotdns.com
ServerAlias y.gotdns.com
the 'index.html' is merely a convention of the default html document for a server to present when serving the contents of a folder on the server, if one is not present, the directory contents are listed instead (unless rules prevent that)
as for $_SERVER, that is PHP code, which is a server side programming language, which would be necessary to add such logic to a program. and would be placed in an 'index.php' rather than an 'index.html', the php file extension tells the server to process the file as a server-side script rather than simply handing the contents of the document wholesale to the browser.
hope this helps