note 76092 added to function.include
| From: | oasis1 at geocities dot com | Date: | Fri, 29 Jun 2007 15:11:53 +0000 |
| Subject: | note 76092 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128091@lists.php.net to get a copy of this message | ||
What a pain! I have struggled with including files from various subdirectories. My server
doesn't support an easy way to get to the root HTML directory so this is what I came up with:
<?php
$times = substr_count($_SERVER['PHP_SELF'],"/");
$rootaccess = "";
$i = 1;
while ($i < $times) {
$rootaccess .= "../";
$i++;
}
include ($rootaccess."foo/bar.php");
?>
This will give you what it takes to get to the root directory, regardless of how many subdirectories
you have traveled through.
----
Server IP: 69.147.83.197
Probable Submitter: 74.129.11.153
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/76092
Del: integrated -- https://master.php.net/note/delete/76092/integrated
Del: useless -- https://master.php.net/note/delete/76092/useless
Del: bad code -- https://master.php.net/note/delete/76092/bad+code
Del: spam -- https://master.php.net/note/delete/76092/spam
Del: non-english -- https://master.php.net/note/delete/76092/non-english
Del: in docs -- https://master.php.net/note/delete/76092/in+docs
Del: other reasons-- https://master.php.net/note/delete/76092
Reject -- https://master.php.net/note/reject/76092
Search -- https://master.php.net/manage/user-notes.php