title: website hostname and docroot
body: <p>Is there a way in PHP to get the <strong>hostname</strong> and <strong>document root</strong> from the server?  I'd like to do this without storing them as variables in your php code.  I am reluctant to use $_SERVER because I have heard it is not reliable and subject to attack.  How can this be done on a virtual host?  Does a reliable and safe method exist?</p>