how to address a file

First: If one addresses a file , say for inclusion in php like e g include "../foo.php";, the server sees this as going one level towards the server root and then find the file, if it is there.
Secon, my question: Is there a more general way to address the file in question (for inclusion or whatever). Say I want a file to be included in serveral pages throughout the website, and these pages may be found in several folders, at different levels away from the server root. That is also to say could I make a general statement instead of ../foo.php or ../../foo.php or ../../../foo.php when calling that file?
Lennart EricsonAmateurAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dr_dedoCommented:
you could have a file with list of all files you wish to include and include that file in all other files.
you can use files' absolute path.
e.g.
file include.php
<?php
require_once ("home/usr/etc/xxx/sss/zzz/file.php");
require_once ("home/usr/etc/xxx/ddd/aaa/file5.php");
?>

in any page include file include.php

but, having your include files scattered this way, means that there is a problem with design, and that problem sooner or later will boom your site. do you r best to gather all your include files in one place
0
Lennart EricsonAmateurAuthor Commented:
dr_dedo, thanks.

"but, having your include files scattered this way, means that there is a problem with design, and that problem sooner or later will boom your site. do you r best to gather all your include files in one place"

Nevertheless, this is the case. The question was is there a more general way to write the code so one doesn't need to do ../../ etc?
0
Lennart EricsonAmateurAuthor Commented:
Can anyone explain, please, what's the difference between ../foo.php, ./foo.php and /foo.php?
0
Lennart EricsonAmateurAuthor Commented:
From other sources I have got this answer:
if you're in /meep/bing/  ./foo is /meep/bing/foo, ../foo is /meep/foo, /foo is .. well /foo
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.