korsakov Posted November 8, 2008 Share Posted November 8, 2008 i am using a software module in a subdirectory since i want to keep the files separate from the root. is there a way to define a path at the start of the module so that i don't have to change every link "./path" to "/subdirectory/path"? set_include_path('/subdirectory'); doesn't work but why? thanks for your help! Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/ Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Take off the slash in /subdirectory, otherwise you're pointing to a directory in the root filesystem. Also, you're probably going to want to keep the old path in there too: set_include_path(get_include_path() . PATH_SEPARATOR . 'subdirectory'); Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685013 Share on other sites More sharing options...
korsakov Posted November 8, 2008 Author Share Posted November 8, 2008 Thank you! I am surprised that it doesn't work. Here is the error message: An error occurred in script 'abc' on line xy: include_once(./common.php) [function.include-once]: failed to open stream: No such file or directory Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685021 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Can I see the full script? Or, specifically, 20 lines above and below the set_include_path() and the include() if possible. You're calling set_include_path() BEFORE include(), right? Not trying to be condescending, but I've seen a lot of mistakes like that on this forum, so I just want to make sure. Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685024 Share on other sites More sharing options...
korsakov Posted November 8, 2008 Author Share Posted November 8, 2008 I basically include this module within another program. By the way, if I add "subdirectory" manually, it works. Thanks again! <?php $path = 'subdirectory'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); define('abc_page','index'); include_once( "./common.php" ); Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685028 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Because you have ./ in front of common.php, which automatically means "this folder". Try removing the ./ part. Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685031 Share on other sites More sharing options...
korsakov Posted November 8, 2008 Author Share Posted November 8, 2008 Alright, but this is exactly what i would like to avoid since i would have to change this in many files... Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685034 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 There's no way to change what ./ means, regardless of the include path. You won't have to add subdirectory/ in front at least. =P You could probably write up a quick Perl program to loop through all the files in a folder and fix those. I'll write one if you want. =P Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685035 Share on other sites More sharing options...
korsakov Posted November 8, 2008 Author Share Posted November 8, 2008 You are very kind! But I believe it is better if I move the whole application to the right directory. Thanks again! Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685038 Share on other sites More sharing options...
DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Alright. Good luck. Link to comment https://forums.phpfreaks.com/topic/131862-set_include_path-question/#findComment-685040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.