Forum Moderators: coopster

Message Too Old, No Replies

Base dir question

one file, multiple directories

         

mooger35

5:34 am on Sep 27, 2006 (gmt 0)

10+ Year Member



Hey,

I've been trying to figure a way to do this for awhile tonight and have run into a roadblock... maybe I just need to step away, but I figure this will be quicker. :)

What I am trying to do is have one menu file to include on everypage regardless of directory. This file will be located in an "includes" folder. I need for the images in this menu file to work regarless of the directory the page may be on and same for the links. I could just use the full www url but I'd also like it to work while testing it on my local apache server as well.

so how do I create $path in $path/images/pic1.gif and $path/index.php for all possible directories?

Thanks

barns101

8:27 am on Sep 27, 2006 (gmt 0)

10+ Year Member



For images you would use something like this:

<img src="/images/pic1.gif">

and it would work both online and offline.

encyclo

9:27 am on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For PHP, my preferred method is to call the include in relation to the document root. like this:

<?php include($_SERVER["DOCUMENT_ROOT"]."/directory/file.inc.php"); ?>

This is much more portable than linking to the exact filesystem path, which may differ from one server to the next.