I\'m trying to set up a site that has many reusable headers/footers, style information, etc. Is there anyway to define a global constant/function that can be reused from any
In your header, declare a variable with the root information. Your path to include the header will have to be correct, but from there on out you can use include(MY_ROOT . 'filename.php');
I have been using:
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
include_once('glob.php');
Which sets my include path right at the root of my site. Not sure if it will work for you though, or if there is a better way?
what's the problem?
define('ROOT_DIR', '/var/www/my_page/');
function includeAll() {
include_once(ROOT_DIR . 'file1.php');
include_once(ROOT_DIR . 'file2.php');
include_once(ROOT_DIR . 'file3.php');
include_once(ROOT_DIR . 'file4.php');
}