Hi,

I came across this problem before, when I was working with windows. Not sure 
if the same problem occurs in Linux, i guess not as otherwise there would 
have been tonnes of postings on that then.

Well, basically my script architecture spans over at least 3 directory 
levels. Just for the sake of discussion let my highest directory be A. 
followed by B, and then C.

My A script is the module controller. the B script is the module, and it 
imports all of its functions by importing scripts contained in C.

So my A script has the line : include("B/fileB.php");
My B "fileB.php" script has : include("C/fileC.php");

Theorectically this is sufficient for A to manage my C scripts. However, i 
realised that PHP wasn't able to do that. The reason being that when A 
script is runned, the contents of fileB.php are sort of "pasted" onto the A 
script. Now the A script sort of has a

include("C/fileC.php");

line of code. this will generate an error, as there is no C directory 
relative to the A directory.


1. you may have generated errors if you have, like me, been working with 
multiple directories, and not taken notice of that subtle problem above. The 
work-around is to put

include("B/C/fileC.php");

in the B script.

2. in your case "require" or "include" makes no difference, but there is a 
subtle difference when used in other situations, you might wanna check that 
out when you are free.

3. My example above is slightly different from yours as yours is traversing 
up a tree, mine was traversing down the tree. However, the conclusion still 
stands: take note and display full paths when working with directory levels 
exceeding 2.


If theres anything you'll like to ask about what i said here, or otherwise, 
pl mail me directly, as i dun check this list very often. All the best then! 
=)

kelvin Chan




Message-ID: <[EMAIL PROTECTED]>
From: "Taylor, Stewart" <[EMAIL PROTECTED]>
To: "'Matthew Ralston'" <[EMAIL PROTECTED]>,
   [EMAIL PROTECTED]
Date: Fri, 11 May 2001 11:52:17 +0100
MIME-Version: 1.0
Content-Type: text/plain;
        charset="iso-8859-1"
Subject: RE: [PHP] include("../file.inc");

Either of the first two should work under linux.

I have done similar many times myself
e.g.
require_once "../common/localvars.php";


-Stewart

-----Original Message-----
From: Matthew Ralston [mailto:[EMAIL PROTECTED]]
Sent: 11 May 2001 11:40
To: [EMAIL PROTECTED]
Subject: [PHP] include("../file.inc");


How do you include or require a file that is above the current script in the
directory hierarchy? For example how would I include or require a file whose
path is "../file.inc" relative to the current script? I tried all of:

include("../file.inc");
require("../file.inc");
include("/file.inc");
require("/file.inc");
include("..\file.inc");
require("..\file.inc");
include("\file.inc");
require("\file.inc");

but it doen't like any of them. :(
I don't want to use a full path relative to the root of the drive or
webserver folder because the included file and the script may move as the
development server is setup differently to the real web server.

Any ideas?

--
Thanks,

Matt
[EMAIL PROTECTED]
< www.mralston.co.uk />




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to