[thelist] PHP includes (how to call from subdir)

Andrew Maynes andrew at humanbehaviour.co.uk
Tue Dec 10 07:59:02 CST 2002

I have this which works for both local and the live site server:


if ($_SERVER['SERVER_ADDR'] == "") {
    // A server
    define ("SHOP_ROOT_PATH", DOCUMENT_ROOT . "/sub_dir/shop");
    define ("SHOP_ROOT_URL", "/test/ukshopLIVE/shop");
} elseif (substr($_SERVER['DOCUMENT_ROOT'],1,2) == ":/") {
    define ("SHOP_ROOT_PATH", DOCUMENT_ROOT . "/sub_dir/shop");
    define ("SHOP_ROOT_URL", "/GO_LIVE/shop");
} else {
    define ("DOCUMENT_ROOT", "/home/g/o/go/public_html"); //because server is
broken badly
    define ("SHOP_ROOT_PATH", DOCUMENT_ROOT . "/sub_dir");
    define ("SHOP_ROOT_URL", "/shop");
    require_once(DOCUMENT_ROOT . "/shared/html_helper.php");
}; // end if

tried that, but failed. I think it's because it ends up search for a
folder called /apache/htdocs.... within the includes folder, even if
when it is preceded with a c:/, but this might be because my php and
docroot are on different drives.

On Sat, 7 Dec 2002 10:18:04 -0500 j.d. welch wrote:

> sure, you can do it like that, but i think it's worth mentioning that
> you can change the include_path directive per directory. in an
> .htaccess file in your DocumentRoot, add something like:
> php_value include_path=".:/path/to/my/includes:/some/other/path"

that's a good suggestion, I'm trying to get php running as a module
rather than a CGI install, to get this working. Lots of my scripts are
breaking up so I have to work out the problems. I'll give it a shot on
m.e.o the next time I meddle with my code.

More information about the thelist mailing list