Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.