phat code If you hear an onion ring, answer it.
Main

Projects

Downloads

Articles

Links

Forum

 

View Message

Back to Messages
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.
 
 
 
 

Reply to this Message

Name
Subject
Message

No HTML is allowed, except for <code> <b> <i> <u> in the message only.
All URLs and email addresses will automatically be converted to hyperlinks.