1. Computing & Technology

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.

©2012 About.com. All rights reserved.

A part of The New York Times Company.