subxero Fri Feb 9 2007 at 6:58 pm Here's what I use
/* Base path: */
if (!defined("SITE_ROOT")) {
$script_dir = dirname($_SERVER["SCRIPT_NAME"]);
if ($script_dir == "/") {
define("SITE_ROOT", "./");
}
else {
define("SITE_ROOT", str_repeat("../", substr_count($script_dir, "/")));
}
} If you put that at the top of your header.php script, you can do things like SITE_ROOT . 'foo.bar' and it'll go back however many directories it needs to go until it gets to the root directory.
|