document paths

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

document paths

Post 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.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

You mean a method that will work from every file in the root directory ("PIP")?
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post 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).
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Maybe this?

Code: Select all

$pro_root = $_SERVER['DOCUMENT_ROOT'] . '/PIP/';
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post by thallish »

thx feyd

ill look into tonight :wink:

(got to go eat now)
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post by thallish »

Oren wrote:Maybe this?

Code: Select all

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