Let's assume we have the following structure:
index.php
config.inc.php
\ lib
\ lib \ common.php
Several parameters like database name, user & co are configured in config.inc.php
. What is the proper way to access them i.e. from a function located in \lib\common.php
. Do I really have to do an include_once("config.inc.php")
within each function there?
It doesn't seem to work if:
config.inc.php
is included once once in index.php, before including\lib\common.php
there- if
config.inc.php
defines all variables before including\lib\common.php
and all other files (this way I would only have to includeconfig.inc.php
in all "central" files at the level ofindex.php
- neither does it work if
config.inc.php
is included at the top of\lib\common.php
Many thanks - I wasn't able to find a solution with Google!
Solution
I included config.inc.php
once in index.php
(as suggested by Galen) and used global (as suggested by David). Everything is working as I would expect it, many thanks!
Later on I will definitely look into auto_prepend
as suggested by n3rd, tkx for that as well!