gilgimech Posted March 26, 2010 Share Posted March 26, 2010 I've got a header on my site. It has a menu on it that needs to include a script in order for it to work. The problem I'm having, is that the include is requiring me to put the path to the script based on where the menu is being called from. example: If I load the page index.php on the base dir. The path for the include on the menu needs to be /includes/include.php If I load the page contact/contact.php. The path for the include on the menu needs to be ../includes/include.php How can I set the include path so it'll work on all pages? Link to comment https://forums.phpfreaks.com/topic/196624-include-help/ Share on other sites More sharing options...
jonsjava Posted March 26, 2010 Share Posted March 26, 2010 try something like this: $root = getenv("DOCUMENT_ROOT"); $inc = "/inc/some_file.php"; include($root.$inc); just make sure that $inc is relative to $root $root will show where your HTDOC root is (the root of your site) Link to comment https://forums.phpfreaks.com/topic/196624-include-help/#findComment-1032347 Share on other sites More sharing options...
gilgimech Posted March 26, 2010 Author Share Posted March 26, 2010 It worked thanks. What I was doing worked up until a couple of days ago. I don't get it. Link to comment https://forums.phpfreaks.com/topic/196624-include-help/#findComment-1032354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.