note 25485 deleted from function.require-once by sniper
| From: | sniper@php.net | Date: | Wed, 29 Jan 2003 04:34:23 +0000 |
| Subject: | note 25485 deleted from function.require-once by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43007@lists.php.net to get a copy of this message | ||
Here is another simple solution to the relative file path with nested requires problem. Set the
root path in a consistant variable (say $root) at the start of each of the php pages (but not the
files that are included).
--- File: ./Page1.php ---
$root = ".";
require "$root/lib/MyLib.php";
# ... #
--- File: admin/page2.php ---
$root = "..";
require "$root/lib/MyLib.php";
# ... #
--- File: lib/MyLib.php ---
# $root set by file including this.
require "$root/lib/db.php";
# ... #