Re: Opendir on site root directory?
| From: | Stuart | Date: | Wed, 11 Mar 2009 09:38:37 +0000 |
| Subject: | Re: Opendir on site root directory? | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289824@lists.php.net to get a copy of this message | ||
2009/3/11 Clancy <clancy_1@cybec.com.au>
> On Tue, 10 Mar 2009 15:12:57 +0000, stuttle@gmail.com (Stuart) wrote:
>
> >Please keep the discussion on-list.
> >
> >2009/3/10 Clancy <clancy_1@cybec.com.au>
> >
> >> Hi,
> >>
> >> After I posted my message to the group today I realised that my program
> >> achieves its
> >> almost infinite flexibility by loading different include files in
> different
> >> circumstances,
> >> and from many different parts of the program. The program always
> specifies
> >> the location
> >> of the include file by the relative path from the root directory. If
> the
> >> uncertainty
> >> about the current working directory you worry about were really a
> problem
> >> this would never
> >> work, but I have been doing this for well over a year, and had never had
> >> any problems.
> >>
> >
> >Just because you haven't experienced a problem with the way you do things
> >yet it certainly doesn't mean the problem isn't there. You're not
> specifying
> >the location of an include file relative to the home directory, it's
> >relative to the current working directory which is not necessarily the
> >directory you expect it to be.
>
> The only circumstances in which my assumption could fail would be if I
> changed to a new
> provider with a different operating system. In the unlikely event of this
> happening all I
> would need to do would be to determine the actual directory, and chdir to
> the desired one.
> This would require at most half a dozen lines of code at the start of the
> program, so it
> would not be a significant hassle.
Like I said it's up to you what you decide to care about. One of the many
things I choose to care about is writing portable code, an important aspect
of which is not relying on absolute file locations or server configuration
as far as possible.
-Stuart
--
http://stut.net/