I have following files structure.
config.php
header.php
page.php
footer.php
The header.php
includes the config.php
file and and page.php
includes header.php
:
header.php
include ('config.php');
page.php:
include ('header.php');
include ('footer.php');
Now on this page.php
if I want to access any function which is in config.php
, it gives error as it cannot access the functions in config.php
file.
It works if I include config.php
file in the page.php
also. However in this way I have to include that file in each of the page.
Is there anyway to include that file in the header.php
file so that I don't have to include in each page?
Edit: config.php is very simple and has only connection string. Here is the content:
define('SOME_CONSTANT', 'xxx');
try {
$db = new PDO("odbc:Driver="..);
} catch(PDOException $e){
echo $e->getMessage();
die();
}