Not sure what this topic is called, but I want to get a better understanding of how to traverse directories.
What is the difference between these?
include ('../includes/header.html');
include ('./includes/header.html');
include ('/includes/header.html');
include ('includes/header.html');
Debbie
DoubleDee:
What is the difference between these?
[QUOTE=DoubleDee;4797377]
include ('./includes/header.html');
./ is the current directory
include ('../includes/header.html');
[/quote]
…/ goes up a level from the current directory
/ goes all the way up to the top, to the root directory
This gets it from the current directory too, just like ./
So it doesn’t navigate anywhere?
If so, what purpose does it serve?
…/ goes up a level from the current directory
So it is a “relative” reference?
/ goes all the way up to the top, to the root directory
So it is an “absolute” reference?
include ('includes/header.html');
This gets it from the current directory too, just like ./
So why would you use one (./) over the other ( )??
Debbie
The purpose of ./ is to point to the current directory.
Yes. Both ./ and …/ are relative from the current directory.
Yep, starting a path with / will always get you to the root, it’s an absolute reference.
Sometimes you will want to use ./ to explicitly declare your intentions.
At other times, you may want to leave it unstated, so that the path can be more easily passed to other systems that may want to handle it.
I think I may have figured out why the code I am typing in from my book is causing me so much grief…
When I run things in NetBeans, my Web Root is…
"http://localhost/02_MyCoffeeShop/"
but on my shared hosting the Web Root is…
"http://www.MySite.com"
When I am using the various syntax we talked about above, I think is working differently whether I am in one environment or another.
For example, “/” defines “root” but maybe that is different in NetBeans versus my web account?! :-/
Can someone help me figure this out?
Debbie
$_SERVER[‘DOCUMENT_ROOT’] should be of some help there.