title: Get root url of the site in PHP
body: <p>Consider my project directory structure as follows,</p>
  
  <pre><code>-public_html
    -projects
      -folder1
        index.php \\code is written here
      +folder2
    +downloads
  </code></pre>
  
  <p>I am trying to get the root directory through <code>$_SERVER['DOCUMENT_ROOT']</code>, but it seems the returned string is not in the form I expect.</p>
  
  <p>My directory inside my website is (basically in) <code>public_html/projects/folder1</code>. Using document root, the returned string is as follows when implemented on a website,
  <code>/home/site_name/public_html</code> which is not going to work if the link is to be shared, cause I am using it to store the file in a directory. So, I want something like it should return, <code>www.site_name.com/downloads</code></p>
  
  <p>The <code>__DIR__</code> is giving the whole document path from where it is called(<code>folder1/index.php</code>), but I want to get into the main folder ( <code>public_html/downloads</code> ), not in the same folder as the index file is.</p>
  
  <p>Are there any other php functions that can help to reach the <strong>downloads folder</strong> in public_html and which can be accessed like, www.sitename.com/downloads/...</p>