homepage Welcome to WebmasterWorld Guest from 54.197.94.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Include file in folder above root folder - how?
Patrick Taylor




msg:3421732
 1:06 pm on Aug 14, 2007 (gmt 0)

I have a .php script in a folder one level above my website root, and I'd like to include it in pages in various website subfolders, some below the root.

How can I do this? Can I use ($_SERVER['DOCUMENT_ROOT'] in the path in some way? Advice would be appreciated.

 

SixTimesEight




msg:3421733
 1:11 pm on Aug 14, 2007 (gmt 0)

Use the actual server directory path.

ex. include('/home/username/include.php');

[edited by: SixTimesEight at 1:11 pm (utc) on Aug. 14, 2007]

Habtom




msg:3421741
 1:15 pm on Aug 14, 2007 (gmt 0)

Can I use ($_SERVER['DOCUMENT_ROOT'] in the path in some way?

I don't know how that can be done, but it is interesting to find out.

How about just going one step up from the root "../folderabove".

-------------
Apologies if this is offtopic but I want to know
a CSS stored in this folder, would it be ok with search engines?

Patrick Taylor




msg:3421746
 1:23 pm on Aug 14, 2007 (gmt 0)

Yes, actual server directory path - that worked. Many thanks.

I can't use '../folderabove' because the .php include exists at various folder levels on the site, so the path has to be absolute.

[edited by: Patrick_Taylor at 1:26 pm (utc) on Aug. 14, 2007]

Habtom




msg:3421749
 1:24 pm on Aug 14, 2007 (gmt 0)

<edit>Your edit answered my question </edit>

[edited by: Habtom at 1:25 pm (utc) on Aug. 14, 2007]

coopster




msg:3422382
 2:07 am on Aug 15, 2007 (gmt 0)

There is a tip on how to accomplish this very task in our PHP Forum Library [webmasterworld.com] in the thread titled Good PHP solutions to small problems [webmasterworld.com] (very last message in the thread).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved