Michael A. Peters wrote: > PJ wrote: > >>> >> I hope I'm not out of place here, but I have a problem that seems to be >> related. >> I am using some include statements for page headers with the pages in >> various directories on the site. The problem is this... if I put >> relative statements in the page (header.php) like ../images/file.jpg and >> ../file.php etc, if the page into which I include header.php is not in >> the top level directory, the links do not work and I have to copy >> header.php to header1.php and change the references to /images otherwise >> images are not displayed and links to not work in href. >> >> e.g.: >> 1. top level file books.php >> include ("lib/db1.php"); // Connect to database >> include ("header1.php"); >> >> 2. subdirectory: /authors/a.php >> include "../header.php"; >> >> I thought that using referencing the top level of the directory tree >> (../) would work form anywhere within the tree? >> Am I the victim of my own misconceptions here? >> TIA to set me straight. > Easy to solve. I neglected to mention, although, it must be fairly obvious that I'm fairly new to all this ["newbie" but not virgin :-) ] Comments below --> > ini_set("include_path", > "/srv/domain/phpinclude:/srv/domain/record_include:/srv/domain/process_include"); > 1. Where to I put it? 2. srv = ? domain = ? phpinclude = ? record, process... = ? server, but like what? a url? > > Then just call it without path - IE > > include('foo.inc'); > > php will first look for foo.inc in /srv/domain/phpinclude, then in > /srv/domain/record_include, etc. > > make directories for your includes, preferably outside the web root, > and define your include path at the top of your script. > > I personally don't like to have . as part of my include path, and > relative include paths (id somedir/foo.inc) are IMHO an even worse > practice. What do you suggest as a better prctice? -- Phil Jourdan --- pj@xxxxxxxxxxxxx http://www.ptahhotep.com http://www.chiccantine.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php