Ok the problem is quite hard to explain, but i'll try to keep it as
simple as i can. Imagine I have the following structure of my files
and folders:
/root/global.inc
|__/files/foo.php
|__/utils
|__/logs/logger.inc
When I run foo.php I get the following error:
==========
Fatal error: require_once() [function.require]: Failed opening
required '../../global.inc' (include_path='.;E:\www\root\') in E:\www
\root\utils\logs\logger.inc on line 3
==========
That error occurs because
1) "global.inc" is included ("required") into "logger.inc" and
"foo.php"
2) "logger.inc" is included into "foo.php"
See, foo.php includes its file as "../global.inc" and logger.inc
"../../global.inc" (note relative path differs)
So if you now try to run "foo.php" the require_once from "logger.inc"
would start looking for "global.inc" relatively /root/files which is
wrong.
My question is... how do I make PHP include files relative to their
location not their current "include" directory?
PS
I know one solution but i don't like it at all. It makes use of the
following trick in each potentially included file:
/* the following will rectify the above problem when inserted to
logger.inc */
require_once(dirname(__FILE__)."/../../global.inc");