Forum Moderators: coopster

Message Too Old, No Replies

php includes

relative vs absolute paths

         

D_Blackwell

2:08 am on Aug 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Typically, I name my files relatively. Things are not usually so complex that I have difficulty keeping track of what goes where. In this case I have a site that will have several includes with identical XHTML but, unusually for me, they are going to be plugged into directories through multiple levels, which would make my relative naming a real pain to implement, and also to keep track of.

Are there any particular upsides/downsides to going entirely with absolute paths on this site? Does the absolute path slow anytning up?

vinyljunkie

2:51 am on Aug 2, 2005 (gmt 0)

10+ Year Member



To my knowledge, there aren't any performance issues with using absolute paths. Personally, I prefer them because I don't have to worry about a script breaking because I decided to change my directory structure or something like that.

coopster

12:40 am on Aug 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I keep all my includes files outside of the document root, where the public cannot get to them. Then, you can either use an absolute path or relative path, whichever you choose. Often times you'll see folks employ a "config" script or something along those lines that sets "sitewide" variables, such as the path to the includes files.

One approach you may find handy can be found in our PHP Library [webmasterworld.com] under the Good PHP solutions to small problems [webmasterworld.com] thread, message number 17.