1. Home
  2. Computing & Technology
  3. PHP / MySQL

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

By Angela Bradley, About.com

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.
More PHP / MySQL Quick Tips
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn PHP
  5. Find Document Root - PHP Document Root - Install File Document Root

©2009 About.com, a part of The New York Times Company.

All rights reserved.