Re: note 9379 added to include

From: Date: Tue, 31 Oct 2000 13:09:52 +0000
Subject: Re: note 9379 added to include
Groups: php.notes 
Request: Send a blank email to php-notes+get-7204@lists.php.net to get a copy of this message
As mentioned before, you could also use include_once/require_once in PHP 4 to help in this problem. A note pointing this has been added to your contribution. --- ryanflynnn@hotmail.com wrote: > 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. > > http://www.php.net/manual/function.include.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: > php-notes-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/

« previous php.notes (#7204) next »