galvin Posted January 23, 2010 Share Posted January 23, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/189496-syntax-for-paths-in-different-directorys-very-basic-question/ Share on other sites More sharing options...
premiso Posted January 23, 2010 Share Posted January 23, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/189496-syntax-for-paths-in-different-directorys-very-basic-question/#findComment-1000257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.