noastudio Posted April 11, 2007 Share Posted April 11, 2007 if you have a file like a.php that includes sys/b.php b.php want to include ../extend/c.php it will try to find the file relative to a.php. How can I set it to search for c.php relative from b.php Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/46545-relative-to-include/ Share on other sites More sharing options...
noastudio Posted April 11, 2007 Author Share Posted April 11, 2007 Before anyone asks: Apache/2.2.4 PHP/5.2.1 win2003 Quote Link to comment https://forums.phpfreaks.com/topic/46545-relative-to-include/#findComment-226582 Share on other sites More sharing options...
wildteen88 Posted April 11, 2007 Share Posted April 11, 2007 you wont as the included file will be included into a.php any file paths that is in b.php will be relative from a.php and not b.php. This how includes work. What you might want to do is set up a constant and call it ROOT that has an absolute path to your websites root, example path: /usr/mysite_com/public_html/ Then when you go to use include you do something like this: include ROOT . 'path/to/script/from/root/folder'; That will make your include use absolute paths rather than relative. Or another option is to add the extended folder to the include_path if you have access to the php.ini, or you can use .htaccess / ini_set to modify the php configuration. Quote Link to comment https://forums.phpfreaks.com/topic/46545-relative-to-include/#findComment-226656 Share on other sites More sharing options...
Koobi Posted April 13, 2007 Share Posted April 13, 2007 i agree with wildteen's suggestion for using ini_set(). you can do that from within your PHP scripts and it makes life a whole lot easier because maintenance is easy and porting your code isn't an issue. Quote Link to comment https://forums.phpfreaks.com/topic/46545-relative-to-include/#findComment-228318 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.