* Thus wrote Allex ([EMAIL PROTECTED]): > Hi all, > > What's the syntax for including/requiring files located in directories > different than the root directory? Especially files from different sub > directories under the root? Going down ("classes/globals.php") is ok, > but going up ("../globals.php") makes problems
What you need to pay attention to is the php.ini setting: include_path By default there is a value as '.' meaning relative to the calling script. What might be a good idea is adding a path to the root of your includes script to the setting (ie. /path/to/web_root) So all inlucdes no matter what file is including them uses the same syntax. index.php: include_once('classes/globals.php') dbase.php: include_once('classes/globals.php') controller.php: include_once('classes/dataaccess/dbase.php') > > root (dir) > +-classes (dir) > | +-interface (dir) > | | |-controller.php > | +-dataaccess (dir) > | | |-dbase.php > | |globals.php > |index.php > | > You might want to consider moving your included files outside your public web tree: home (dir) +-web root (dir) | |-index.php | +-include root (dir) +-classes (dir) | +-interface (dir) | | |-controller.php | +-dataaccess (dir) | | |-dbase.php | |globals.php Then set the php_include path to /path/to/include root/ Then all your include/requires are made relative to the include root. HTH, Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php