Page 1 of 1

Files and PHP... question

Posted: Wed Oct 24, 2007 12:42 pm
by Toshiba23
Ok, I'm really confused on how level of files work in PHP in folders...

Such as... lets say I have a file in a folder one level below the current folder my script is running in... how do I get to the folder below me?

require("../folder_below/file.php"); // Would this work?

Also, I noticed phpBB uses phpbb_root_path for ever file requirement it does, I'd like to use that, and I tried... but my server just tells me nothing is there you idiot.

Basically, what is the difference between './' and '../' and what are easy ways to get to folders throughout my server?

Thankies =) :D :wink:

Posted: Wed Oct 24, 2007 1:09 pm
by reecec
do you mean folder above..

Say you have a tree like this

Code: Select all

Folder 1
   - Folder 2
        -Folder 3

If you where in folder 2 to get back to folder 1 you would use "../"
to get down to folder 3 you would do as normal "folder3"

any help

reece

Posted: Wed Oct 24, 2007 1:30 pm
by Christopher
You should be able just do:

Code: Select all

require("folder_below/file.php");
It is a good idea to understand what all the settings and superglobals are on your server. To do this write and run the following script:

Code: Select all

phpinfo();

Posted: Wed Oct 24, 2007 2:32 pm
by Toshiba23
arborint wrote:You should be able just do:

Code: Select all

require("folder_below/file.php");
It is a good idea to understand what all the settings and superglobals are on your server. To do this write and run the following script:

Code: Select all

phpinfo();
Will requirements always start from the bottom of the folder tree?

Posted: Wed Oct 24, 2007 4:44 pm
by califdon
Toshiba23 wrote:
arborint wrote:You should be able just do:

Code: Select all

require("folder_below/file.php");
Will requirements always start from the bottom of the folder tree?
No, it always starts from the folder in which the script is running. ./ means the same folder as the script is in (which you don't need to state explicitly), ../ means the parent folder.

Posted: Wed Oct 24, 2007 4:51 pm
by Toshiba23
what's the easiest way to start from the root level?

Posted: Wed Oct 24, 2007 4:59 pm
by seppo0010
Toshiba23 wrote:what's the easiest way to start from the root level?
$_SERVER['DOCUMENT_ROOT']

Posted: Thu Oct 25, 2007 11:05 am
by xitura
Toshiba23 wrote:what's the easiest way to start from the root level?
I think .../ gets you to the top.