justcrapx Posted February 4, 2007 Share Posted February 4, 2007 I have an include folder for my scripts inside the root dir, all scripts are also included in the root. When i moved some of my scripts to a spesific folder the include function seeks the file inside that spesific directory, i want to target the original inc folder. this is the include line include 'inc/functions.php'; i have tried this but didnt work include '../inc/functions.php'; Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/ Share on other sites More sharing options...
yzerman Posted February 4, 2007 Share Posted February 4, 2007 try: include('../path/to/filename'); Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176491 Share on other sites More sharing options...
justcrapx Posted February 4, 2007 Author Share Posted February 4, 2007 doesnt work =( Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176496 Share on other sites More sharing options...
yzerman Posted February 4, 2007 Share Posted February 4, 2007 well, it depends on where your file resides. for instance, here is a basic layout for a site with includes: -root --inc (dir) --admin(dir) ---users(dir) ---mods(dir) --themes In the case like this - include('../inc/functions.php') a script with this included inside the mods dir, would look for the folder inc in the admin dir, instead of the root dir. to make it look deeper for the root dir, add another .., like include('../../inc/functions.php') if thats not it, I have no clue dude Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176504 Share on other sites More sharing options...
shoz Posted February 4, 2007 Share Posted February 4, 2007 You can use the $_SERVER['DOCUMENT_ROOT'] variable to access the root directory. Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176509 Share on other sites More sharing options...
yzerman Posted February 4, 2007 Share Posted February 4, 2007 You can use the $_SERVER['DOCUMENT_ROOT'] variable to access the root directory. when I looked this up earlier (because thats what I was going to say as well) it said that $_SERVER['DOCUMENT_ROOT'] was only the root folder for the script was running in - does this mean it is the folder the script resides in, or the root folder for the server? Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176515 Share on other sites More sharing options...
justcrapx Posted February 4, 2007 Author Share Posted February 4, 2007 Ah thank you bot, i figured out the issue now. TOPIC SOLVED =) Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176516 Share on other sites More sharing options...
shoz Posted February 4, 2007 Share Posted February 4, 2007 You can use the $_SERVER['DOCUMENT_ROOT'] variable to access the root directory. when I looked this up earlier (because thats what I was going to say as well) it said that $_SERVER['DOCUMENT_ROOT'] was only the root folder for the script was running in - does this mean it is the folder the script resides in, or the root folder for the server? The root directory where apache serves files for the server. EDIT: Decided to clarify. Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176520 Share on other sites More sharing options...
yzerman Posted February 4, 2007 Share Posted February 4, 2007 sweet, learn something new every day, thanks Link to comment https://forums.phpfreaks.com/topic/36979-solved-including-from-the-root-directory/#findComment-176521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.