title: Is there a good alternative to $_SERVER['SERVER_NAME']?
body: <p>I read the following comment on <a href="http://php.net/manual/en/reserved.variables.server.php" rel="nofollow noreferrer">PHP doc pages</a>:</p>
  
  <blockquote>
    <p>"Be warned that most contents of the Server-Array (even
    $_SERVER['SERVER_NAME']) are provided by the client and can be
    manipulated. They can also be used for injections and thus MUST be
    checked and treated like any other user input."</p>
  </blockquote>
  
  <p>An then I saw a topic here <a href="https://stackoverflow.com/questions/6474783/which-server-variables-are-safe/6474936#6474936">on StackOverflow saying that $_SERVER['SERVER_NAME'] is partly server controlled</a>.</p>
  
  <p>Can I trust on this value to get the url of my website? If I can't really trust $_SERVER['SERVER_NAME'], how can I get this value? What are some possible alternatives and their pro and cons?</p>
  
  <p><strong>OBS:</strong> <em>PHP 5.3 on Apache, Unix.</em></p>