/ Published in: PHP
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.
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function dynRoot() { for ($i=0; $i < $levels - 1; $i++) { $relativeDir .= "../"; } return $relativeDir; } ?>
URL: http://www.devtek.org/tutorials/dynamic_document_root.php