Page 1 of 1
Path variable??
Posted: Wed Aug 06, 2008 5:27 pm
by jkashu
I need to develop software for use on multiple websites. How do I avoid having to change the inclusion path on ALL pages??
include("$PATH/login.php");
Can I somehow define a path variable for the whole site???
Thanks!
Re: Path variable??
Posted: Wed Aug 06, 2008 5:36 pm
by pickle
Look into $_SERVER['DOCUMENT_ROOT'] and maybe get_cwd()
Re: Path variable??
Posted: Wed Aug 06, 2008 7:57 pm
by dajawu
Or if your making a big application that will be distributed like a Forum, you would want to make a settings page that the end user could change a variable. You would then save the path the end user chooses in a file or DB, then pull it up whenever you need it.
Re: Path variable??
Posted: Thu Aug 07, 2008 10:50 pm
by jkashu
That's what I was thinking, but doesn't the file with the variables have to be included on every page???
Re: Path variable??
Posted: Fri Aug 08, 2008 6:24 am
by pkbruker
I've used this technique several times:
1. Make some sort of settings file (i.e. config.inc.php), and make sure it's always included no matter which page is displayed.
2. Decleare this in config.inc.php:
Code: Select all
DEFINE("INCLUDE_PATH","the/path/yeah/");
3. When including other stuff, do like this:
Code: Select all
require INCLUDE_PATH.'the_included_file.php';
Voila! And, you will most surely need more setting variables, which you can decleare in config.inc.php (i.e. mySQL username, password).