Lennart Ericson
asked on
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?
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?
ASKER
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?
"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?
ASKER
Can anyone explain, please, what's the difference between ../foo.php, ./foo.php and /foo.php?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can use files' absolute path.
e.g.
file include.php
<?php
require_once ("home/usr/etc/xxx/sss/zzz
require_once ("home/usr/etc/xxx/ddd/aaa
?>
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