...

View Full Version : Simple PHP include() Question



boko
06-04-2007, 02:15 AM
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.

rafiki
06-04-2007, 02:21 AM
it doesnt have to be in the same directory


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 :)

boko
06-04-2007, 02:25 AM
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 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?

rafiki
06-04-2007, 02:39 AM
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 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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum