1. Computing

Discuss in my forum

Finding the Document Root

Document root is sometimes needed to install scripts, find it with Getenv ()

By , About.com Guide

You're installing a script. You're moving along, doing fine, when suddenly you need to know the document root. How can you find it? Well you could e-mail tech support and wait 15 hours for them to let you know, or you could use a simple PHP script with getenv (). Here's how:
 <?php 
 //Gets the document root 
 $root = getenv("DOCUMENT_ROOT") ; 
 Echo $root; 
 ?> 
And that's all. These few lines of code should return the document root. Hopefully keeping this small script around will save you future install headaches.
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn PHP
  5. Find Document Root - PHP Document Root - Install File Document Root

©2013 About.com. All rights reserved.