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.
- function dynRoot()
- $levels = substr_count($_SERVER['PHP_SELF'],"/");
- for ($i=0; $i < $levels - 1; $i++)
- $relativeDir .= "../";
- return $relativeDir;
You need to login to post a comment.