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!
Path variable??
Moderator: General Moderators
Re: Path variable??
Look into $_SERVER['DOCUMENT_ROOT'] and maybe get_cwd()
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Path variable??
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??
That's what I was thinking, but doesn't the file with the variables have to be included on every page???
Re: Path variable??
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:
3. When including other stuff, do like this:
Voila! And, you will most surely need more setting variables, which you can decleare in config.inc.php (i.e. mySQL username, password).
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/");Code: Select all
require INCLUDE_PATH.'the_included_file.php';