Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-04-2007, 01:15 AM   PM User | #1
boko
New Coder

 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
boko is an unknown quantity at this point
Simple PHP include() Question

I've got a simple question about the include function. I've searched the web and found different, unclear answers and searched the forums and found no results. In order to use the include("") function to insert a menu/header into my pages, does the file have to be in the same directory? I've experimented with it and can't find a way to get it to work.

Any help is appreciated.
boko is offline   Reply With Quote
Old 06-04-2007, 01:21 AM   PM User | #2
rafiki
Senior Coder

 
rafiki's Avatar
 
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
rafiki will become famous soon enough
it doesnt have to be in the same directory
PHP Code:
include(./page.inc); 
//will take it back or up on level in the directory 
need to no more check the official manual at www.php.net/include.php
or ask here
__________________
Get Firefox Now
rafiki is offline   Reply With Quote
Old 06-04-2007, 01:25 AM   PM User | #3
boko
New Coder

 
Join Date: Oct 2005
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
boko is an unknown quantity at this point
Is it possible to link it back up to the root directory? I've messed around with it a few different ways, but nothing has worked. I tried:
PHP Code:
<?php include("/phpincludes/menu.txt")?>
menu.txt is, of course, in the directory phpincludes at the root of my site. Is there a different way to do this?

Last edited by boko; 06-04-2007 at 01:27 AM..
boko is offline   Reply With Quote
Old 06-04-2007, 01:39 AM   PM User | #4
rafiki
Senior Coder

 
rafiki's Avatar
 
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
rafiki will become famous soon enough
Quote:
Originally Posted by boko View Post
Is it possible to link it back up to the root directory? I've messed around with it a few different ways, but nothing has worked. I tried:
PHP Code:
<?php include("/phpincludes/menu.txt")?>
menu.txt is, of course, in the directory phpincludes at the root of my site. Is there a different way to do this?
$_SERVER['DOCUMENT_ROOT']/phpincludes/menu.txt <= include that
__________________
Get Firefox Now
rafiki is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:21 AM.


Advertisement
Log in to turn off these ads.