Jump to content

set_include_path question


korsakov

Recommended Posts

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

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');

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. ;)

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" );

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.