note 9379 deleted from function.include by sniper

From: Date: Wed, 29 Jan 2003 04:03:11 +0000
Subject: note 9379 deleted from function.include by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-42971@lists.php.net to get a copy of this message
[Editor's note: as indicated before, include_once/require_once should help in this problem. Only in PHP 4] I had a problem with the "include". One of PHP's biggest problems is that if (as someone previously noted) if file A includes file B and file B wants to include file C and the files are in different directories there can be complications, because file B's include path automatically shifts to whatever file A's may be. A bit confusing to say the least. But there is hope! You can work around this problem by creating one page in every directory and sub-directory of your project. Name this file "path.php" in every directory. In path.php simply put: define("BASE", "path-to-root-project-directory"); then, at the top of every php page, before any other includes, include path.php. Then, before any include statements, use the BASE global. include "library.php" becomes: include BASE."library.php" Now you simply structure all includes to be relative to the project's base directory, and every page will know how to get there. This explanation makes it sound worse than it is. Hope this helps someone out there.

« previous php.notes (#42971) next »