note 25485 added to function.require-once
| From: | hotmail at rack1 dot php dot net | Date: | Wed, 25 Sep 2002 18:57:53 +0000 |
| Subject: | note 25485 added to function.require-once | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37237@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";
# ... #
--
http://www.php.net/manual/en/function.require-once.php
http://master.php.net/manage/user-notes.php?action=edit+25485
http://master.php.net/manage/user-notes.php?action=delete+25485
http://master.php.net/manage/user-notes.php?action=reject+25485