Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.