Tsjompie Posted December 3, 2006 Share Posted December 3, 2006 Hi :DI use an include in my index page, referring to some functions I use to make changes to images (e.g. hovering and reloading images).That same functions needs to be available at the subpages of the site.The include looks like: include("libs/main.php");BUT,when I use that same code the sub page doesn't load because of the location of the main.php is wrong. It does work when I include like: include("[b]../[/b]libs/main.php");However... that "simple" change to the location of the main.php leads to multiple templates because the site is 3 levels deep.Is there another way to refer to script files located in (sub)folders?Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/ Share on other sites More sharing options...
keeB Posted December 3, 2006 Share Posted December 3, 2006 The simple way, modify your include path to include your libs directory. This can be done via php.ini, or through a script. Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/#findComment-134494 Share on other sites More sharing options...
Tsjompie Posted December 3, 2006 Author Share Posted December 3, 2006 I do use the server of my ISP.So.. including the libs folder to the path seems not possible to me? Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/#findComment-134517 Share on other sites More sharing options...
papaface Posted December 3, 2006 Share Posted December 3, 2006 I believe it is simply a case of working up from the lowest directory:If libs is in public_html, or your wwwroot then use include("/libs/main.php");I believe that will work... Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/#findComment-134521 Share on other sites More sharing options...
Tsjompie Posted December 3, 2006 Author Share Posted December 3, 2006 As soon as I add / or ../ the page functionality changes from the index page to the subpage and visa versa. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/#findComment-134528 Share on other sites More sharing options...
redbullmarky Posted December 4, 2006 Share Posted December 4, 2006 i either refer to a file in one of these three ways:[code]<?php// when i wanna include something outsite the web rootinclude('/var/www/vhosts/mysite.com/scripts/myfile.php');// when i wanna include something within my web rootinclude($_SERVER['DOCUMENT_ROOT'] . '/includes/myfile.php');// when i wanna include something that is ALWAYS in the same directory as the file that i put this line ininclude(dirname(__FILE__) . '/myfile.php');?>[/code]that should help you on your waycheersMark Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/#findComment-134586 Share on other sites More sharing options...
Tsjompie Posted December 4, 2006 Author Share Posted December 4, 2006 Mark,Those lines are great!!!Thank you!Do you fulfill people’s needs using rac?Tsjompie Quote Link to comment https://forums.phpfreaks.com/topic/29335-refer-to-folder-using/#findComment-134724 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.