Revision: 46075
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 12, 2011 16:17 by jdesignweb
Initial Code
<?php function dynRoot() { $levels = substr_count($_SERVER['PHP_SELF'],"/"); for ($i=0; $i < $levels - 1; $i++) { $relativeDir .= "../"; } return $relativeDir; } ?>
Initial URL
http://www.devtek.org/tutorials/dynamic_document_root.php
Initial Description
I like to build modular sites, always have, always will. We used to use frames to set up navigation links and headers and footers but there were so many issues with doing that. Then along came Server Side Includes (SSI) which allowed people to include those files at runtime into the page. Life was good. PHP has this functionality, but one of the seriously frustrating things about it is the lack of being able to include files relative to the website root directory. This means you have to use the ../ syntax to back up a folder, sometimes multiple times, and then drill down through another folder.
Initial Title
Building a dynamic path to the document root for the include function
Initial Tags
Initial Language
PHP