title: Getting hostname or IP address of server in PHP
body: <p>I basically need to create a anchor that will navigate to a different port on the server. For instance, our server is hosted on <code>domain.com:555</code>, we need a link to navigate to <code>domain.com:777</code>. The catch is that it's not always domain.com. We can expect the DNS to malfunction, in which case we will use ip address to navigate like <code>xx.xx.xx.xx:555</code> and <code>xx.xx.xx.xx:777</code>.</p>
  
  <p>I need get the hostname of the server where the PHP script is running. I tried using SERVER_ADDR, but that for reason gives me the private IP of the server.</p>
  
  <p>So how do I get the domain / ip part of the url?</p>