Re: nested includes fails?
| From: | Tumurbaatar S. | Date: | Tue, 04 May 2004 12:22:12 +0000 |
| Subject: | Re: nested includes fails? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9659@lists.php.net to get a copy of this message | ||
I'm not familiar with Linux/Apache, but if they run as Windows/IIS
pair, then I'm afraid that "php.ini" would be shared among all developers
hosting on a single server and my include dir would expose its
contents to other app-s. Though below may be another workaround:
<?php
ini_set('include_dir', '....');
include('blahblahblah');
?>
"Kamesh Jayachandran" <kameshj@fastmail.fm> wrote in message
news:1083666449.25843.3.camel@linux.local...
> Any reason why you want to use require_once with same filename with
> different paths?
> Why don't you set a include_dir as your e:\...\myapp\inc and just
> require 'common.php'.
>
> With regards
> Kamesh Jayachandran
>
>
>
> On Tue, 2004-05-04 at 15:49, Tumurbaatar S. wrote:
> > A brief directory structure:
> >
> > "e:\...\myapp\" - this my web apps root and it contains several
> > subdirs:
> > "e:\...\myapp\members\" - a normal, web shared subdir
> > "e:\...\myapp\inc\" - an include subdir where are located all my
> > include files and this subdir is not web shared
> >
> > (though my Inetpub dir is located in C:, I use IIS's virtual app/dir
> > located in a different volume E:)
> >
> > The above "inc" subdir contains "common.php" which is used by
> > all other script files located anywhere under app root and subdirs.
> > So if a script is located in the "inc" subdir, then it may start with:
> >
> > <?php require_once('common.php') ?>
> >
> > If a script is in the root dir, then:
> >
> > <?php require_once('inc/common.php') ?>
> >
> > and if it is in other subdirs (e.g. "members"):
> >
> > <?php require_once('../inc/common.php') ?>
> >
> > Finally, when my script located in 'members' needs some
> > include file from the "inc" dir, I include it in this manner:
> >
> > <?php require_once('../inc/some_include.php') ?>
> >
> > and I do not include "common.php" directly because
> > "some_include.php" starts with:
> >
> > <?php require_once('common.php') ?>
> >
> > I.e. a rule is:
> > a script does not include "common.php" if it includes
> > some other include file because that include file already
> > includes "common.php".
> >
> > That works fine untill I included 2 and more files:
> >
> > <?php require_once('../inc/some_include.php') ?>
> > <?php require_once('../inc/other_include.php') ?>
> >
> > where each of these include files includes "common.php".
> > In this case, "common.php" is included in a calling script
> > file 2 times, even "require_once()" is used. And this leads
> > to a trouble.
> > Currently, I use absolute pathes hoping that when my app
> > moves to Linux/Appache, relative pathes will work normally.
> >
> >