Page 1 of 1

document paths

Posted: Sun Aug 27, 2006 8:48 am
by thallish
Hi all

I have an issue that I can't wrap my head around.

I have a file in the folder: PIP/folder/file.php and I need to require a file in PIP/anotherfolder/foldermore/fileToRequire.php.
The folder PIP is the root folder of the project.

How do I do that? This need to be a generic method, ie no absolute paths.

Posted: Sun Aug 27, 2006 9:01 am
by Oren
You mean a method that will work from every file in the root directory ("PIP")?

Posted: Sun Aug 27, 2006 9:09 am
by thallish
hi again

I mean a method (or a hint in the right direction :D ) that will work from every file, that being the root folder 'PIP' and all subfolders 'PIP/whateverFolderIWant To Use/.

The idea is that I am creating new folder that users can put files in, and in these folders I have a standard file that needs to get acces to the framework which is in another subfolder of 'PIP'. (I am using the Smarty framework but I guess this is an PHP path issue).

Posted: Sun Aug 27, 2006 9:13 am
by feyd
set_include_path() may be of interest. You can also adjust the include paths using .htaccess files in Apache. Another directive that may be of interest is auto_prepend_file and it's sibling auto_append_file.

http://php.net/ini.core for details.

Posted: Sun Aug 27, 2006 9:16 am
by Oren
Maybe this?

Code: Select all

$pro_root = $_SERVER['DOCUMENT_ROOT'] . '/PIP/';

Posted: Sun Aug 27, 2006 9:16 am
by thallish
thx feyd

ill look into tonight :wink:

(got to go eat now)

Posted: Sun Aug 27, 2006 9:35 am
by thallish
Oren wrote:Maybe this?

Code: Select all

$pro_root = $_SERVER['DOCUMENT_ROOT'] . '/PIP/';
I'll try that too :lol: