Re: including files from different sub directories

From: Date: Fri, 24 Oct 2003 11:33:23 +0000
Subject: Re: including files from different sub directories
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167408@lists.php.net to get a copy of this message
including/requiring a file does not change the directory, the code is simply inserted into the current context. So you should have:
index.php:         include_once('classes/globals.php')
dbase.php:         include_once('classes/globals.php')
controller.php:    include_once('classes/dataaccess/dbase.php')
Allex wrote:
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 Example:
index.php:         include_once('classes/globals.php') -> works fine;
dbase.php:         include_once('../globals.php') -> generates an error;
controller.php:    include_once('../dataaccess/dbase.php') -> error;
root (dir) +-classes (dir) | +-interface (dir) | | |-controller.php | +-dataaccess (dir) | | |-dbase.php | |globals.php |index.php | I'm running PHP 4.3.2 with Apache 2 on WinXP box. Thanks, Allex


« previous php.general (#167408) next »