Jump to content

Archived

This topic is now archived and is closed to further replies.

black.horizons

php includes

Recommended Posts

do included files assume the directory position of the file from which they're included.

e.g.
website/includes/header.php - has links to ../index.htm

a file links.php resides in
website/links.php

if links.php includes /includes/header.php

with a link to index.htm, will the link work, or not?

Share this post


Link to post
Share on other sites
It's a simple enough test to try :)

But yes, relevant to the calling doc, not the included doc I believe.

Regards
Huggie

Share this post


Link to post
Share on other sites
The included files become part of the file including them.

So if you included header.php from the includes folder into links.php which is in the website folder then all paths from header.php go from the website folder and not the lincludes folder.

Share this post


Link to post
Share on other sites
thats what i thought, just i have a lot of sub folders, so for the subfolders i'll have to modify the header.php, and add an extra ../ to every a href. not so bad, unless there's something else i can do?

Share this post


Link to post
Share on other sites
Setting the absolute path at the top of every page seems to work for us - we then just have all inlcudes in one folder (same with scripts etc) and it yanks them out and works out he path.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.