|
Posted by stevenowicki on 05/03/06 11:40
include('somefile.ext') assumes that somefile.ext is in the same
directory as the PHP file containing the include statement. If the
included file is in another directory, for example the parent
directory, then you need to call include('../somefile.ext'). Realizing
that this can be something of a PITA when trying to include it in files
that may be spread over multiple directories, my suggestion is to
define a constant that points to the physical path to the application
root, which would allow you to do something like the following:
//in constants.php included into all page requests
define('APP_ROOT', '/opt/websites/mysite/');
//somewhere else in the application
include(APP_ROOT . 'includes/somefile.ext');
Navigation:
[Reply to this message]
|