title: PHP How to get the root url of a subdomain
body: <p>I used to have my website into a domain like : <code>www.mydomain.com</code><br>
    But now i've created a subdomain 'test' : <code>www.test.mydomain.com</code> and i moved the whole project files there.  </p>
  
  <p>So far so good, the problem is that on my <strong>php</strong> libraries where i call db connection etc, i use the <code>$_SERVER['DOCUMENT_ROOT']</code> which gives me the <strong>URL</strong> without the <strong>subdomain</strong> , e.x. </p>
  
  <pre><code>$file = $_SERVER['DOCUMENT_ROOT'];//gives me www.mydomain.com 
  </code></pre>
  
  <p><strong>But i need to get the root with the subdomain, like</strong> : www.test.mydomain.com</p>
  
  <p><em>I dont want to make a trick like to split the url and add the subdomain thing.</em></p>
  
  <p>Any help would be appreciated.</p>