Re: include_path and relative vs. absolute paths
| From: | neil | Date: | Tue, 17 Aug 2004 12:30:49 +0000 |
| Subject: | Re: include_path and relative vs. absolute paths | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24423@lists.php.net to get a copy of this message | ||
Thanks John
That is a great solution, well at least for my development box where I can
control my php.ini. The jokers who host one of the sites I look after have
the include_path pointing to a non-existent place and won't modify it.
Thanks anyway
Neil
"John Lim" <jlim@natsoft.com.my> wrote in message
news:20040817104641.64977.qmail@pb1.pair.com...
> Good question. I had the same problem when i switched from .asp to .php
>
> Suppose you want to use relative paths, eg. reference child1.php from
> file1.php, where the file locations are:
>
> path/file1.php
> path/child/child1.php
>
> The trick is to generate an absolute path for the current file, and find
all
> relative files based on this absolute path.
>
> eg. in file1.php:
>
> $file1AbsPath = dirname(__FILE__);
> include($file1AbsPath ."/child/child1.php");
>
>
>
> "Neil" <neil@jansons.net> wrote in message
> news:20040817010732.57277.qmail@pb1.pair.com...
> > I am still getting used to .php after moving from .asp and one thing I
had
> > trouble getting my head around was the apparent inability to use
absolute
> > paths for include files.
> >
> > If I change the include_path in php.ini to say -
> > include_path=".;c:\php\site1\inc" then I can access include files either
> > relatively
> > eg. require '../includes/somefile.php'; where the includes folder is at
> the
> > same level as the current folder
> > or absolutely
> > eg. require 'somefile.php'; where the file is either in the same folder
or
> > is c:\php\site1\inc
> >
> > Now the second option is fine except if I have multiple sites on the one
> > server.
> >
> > With .asp it would just read /inc/somefile.inc either from the root of
the
> > site or from a virtual folder but the include_path setting forces all
the
> > sites to use the either the one include folder or at least not use the
> same
> > file names if there are multiple folders specified.
> >
> > Does anyone know another way of dealing with this?
> >
> > Thanks
> >
> > Neil