tags:

views:

39

answers:

3
hj.nm.google.com

How to you look at hj.nm,is it a server named hj.nm?
(What should $_SERVER['SERVER_NAME'] be?)

+1  A: 

could be anything really, but subdomains could be usernames in the DB or, an arbitrary name to separate it from www.domain.name.

so no, it's not necessarily a server named hj.nm

pjammer
+3  A: 

In reality:

hj is a subdomain of nm.domain.name
nm is a subdomain of domain.name
domain is a subdomain (technically) of name

In PHP:

$_SERVER['SERVER_NAME'] in this case might be hj.nm.domain.name
This variable can be defined as anything if running on a virtual host

If you reliably want the web address your PHP script is running at, I believe you can use $_SERVER['HTTP_HOST'];

Chacha102
Your understanding of $_SERVER['SERVER_NAME'] is obviously wrong.
RTFM.... http://www.php.net/manual/en/reserved.variables.server.php
Chacha102
Can you explain "This variable can be defined as anything if running on a virtual host"?
+1  A: 

You can basically look at it in reverse:

  • com - root name
  • google - domain of root name
  • nm - sub domain of "google"
  • hj - sub domain of "nm"

As to the physical implementation, you cannot tell from the name given. It is possible to host com, google.com, nm.google.com, and hj.nm.google.com all on the same server as well as hosting hj.nm.google.com on more than one server.

GrayWizardx
I've changed it.
My answer is still essentially correct if that is to be considered a valid DNS record (i.e. "host" name).
GrayWizardx