Jump to content

syntax for paths in different directorys? (very basic question)


galvin

Recommended Posts

I have an "includes" folder and when I reference the stuff in them, I wrote it out as "includes/file.php".  This worked fine unless I use this syntax in a file that is in another folder on the same level as "includes."

 

Basically gives an error that says, "hey, we can't find that path in THIS directory."

 

But I found that if I change the syntax to "../includes/file.php", it works fine.

 

In other words, it seems like adding "../" to the beginning of a path essentially tells the file to find this file regardless of whether it's in this directory or another one.

 

Works perfect, just want to make sure there are no possible negative repercussions for using that syntax.

 

In a nutshell, is using "../" the proper way to always reference paths (aside from writing out the full path each time).

 

Thanks,

Greg

It is not always the best, as it all depends on how it is coded. An alternative is using $_SERVER['DOCUMENT_ROOT'] to specify the absolute path to the file.

 

But as long as you code it properly either way is fine.

Archived

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

×
×
  • Create New...

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.