The includes are evaluated from the location of the running script. When you include
another file, you are essentially pulling the contents of that file into the running script at that place.
For files that should evaluate includes relative to the included file's location, you can do this:
/foo/baz.php
include(dirname(__FILE__) . '/bar.inc.php';
include(dirname(__FILE__) . '/../asdf/qwerty.inc.php'
From the documentation:
__FILE__
is The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__
always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.
dirname
Given a string containing the path of a file or directory, this function will return the parent directory's path.
[http://php.net/manual/en/function.dirname.php] [http://php.net/manual/en/language.constants.predefined.php]