Include statement

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
RiSiCO
Forum Newbie
Posts: 4
Joined: Tue May 20, 2008 4:16 am

Include statement

Post by RiSiCO »

Hello, i have some problems with include statement.

I will show a graphic


*Root
--Home
---Folder
---Folder2
--Forum
---Folder1
---Folder2

In Home i have an index file and i want to include something from Forum Folder

I use

Code: Select all

<?php
include ('folder/file.php');
?>
But this work only for subfolders, how can i include something from upper folders?

Thank You!
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Include statement

Post by Kieran Huggins »

it works just like any unix file path:

Code: Select all

include ('../folder/file.php');
or better yet:

Code: Select all

include ($_SERVER['DOCUMENT_ROOT'].'/folder/file.php');
RiSiCO
Forum Newbie
Posts: 4
Joined: Tue May 20, 2008 4:16 am

Re: Include statement

Post by RiSiCO »

Thank you, i will try :)
Post Reply