Here’s sort of a silly question. When File A does an include() of file B, and file B does an include of file C, and all the the paths are relative, are the ‘child’ references relative to their own path, or to the ‘master’ file (file A) in which they’re included?
for example:
directory structure
Root
header.html (File B)
/images / logo.png (File C)
/site / index.php (File A)
index.php contains:
include(‘../header.html’);
header.html contains:
include(‘images/logo.png’);
Will this work? Or since index.php is the ‘master’ file, will it try to look for ‘images’ within the ‘sites’ folder?
They are always relative to the “master” file. Included files are treated as “injections” of source code into the main script, so they behave as if they were inside the main script.
To address something relative to the actual current file, use the
__FILE__and__DIR__constants that always point to the file they’re in.