Forum Moderators: coopster

Message Too Old, No Replies

How do you specify the path of php includes?

trying to determine the best way to specify include and require files.

         

lampip

2:10 am on Nov 30, 2005 (gmt 0)

10+ Year Member



I use php include and require to include function libraries and blocks of html. I currently specify a relative path with i find a bit annoying (varies with each page). Do most people use relative or absolute paths? And if absolute how do you specify them in a generic way?

thanks,
peter

Vlad

2:51 am on Nov 30, 2005 (gmt 0)

10+ Year Member



I'm no php guru but seems like putting your path in a veriable would be ideal.
make a config file and put something like this in there:

$mypath = "my/path/";

then if you need this path on a page just put:
include ("config.php");
and use $mypath

does this makes any sense?

coopster

2:39 pm on Nov 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld lampip.

Message number 17 in the Good PHP solutions to small problems [webmasterworld.com] dialog found in our PHP Forum Library is a good start. Should give you a few ideas anyway.

lampip

6:39 pm on Dec 1, 2005 (gmt 0)

10+ Year Member



Thanks for pointing me towards that thread. interesting approach, i will look into it.

peter