Files and PHP... question

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
Toshiba23
Forum Newbie
Posts: 4
Joined: Wed Oct 24, 2007 12:39 pm

Files and PHP... question

Post 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:
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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();
(#10850)
Toshiba23
Forum Newbie
Posts: 4
Joined: Wed Oct 24, 2007 12:39 pm

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.
Toshiba23
Forum Newbie
Posts: 4
Joined: Wed Oct 24, 2007 12:39 pm

Post by Toshiba23 »

what's the easiest way to start from the root level?
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post by seppo0010 »

Toshiba23 wrote:what's the easiest way to start from the root level?
$_SERVER['DOCUMENT_ROOT']
xitura
Forum Newbie
Posts: 20
Joined: Fri Sep 07, 2007 11:25 am

Post by xitura »

Toshiba23 wrote:what's the easiest way to start from the root level?
I think .../ gets you to the top.
Post Reply