RE: [PHP] HELP: Nested include(...)'s take relative paths not int uitively
| From: | Alex Hogan | Date: | Tue, 10 Feb 2004 20:08:11 +0000 |
| Subject: | RE: [PHP] HELP: Nested include(...)'s take relative paths not int uitively | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-177316@lists.php.net to get a copy of this message | ||
Are you saying that it's better not to use relative paths on include(...)'s,
require(...)'s and their (x)_once(...) cousins?
That seems awkward to me.
Why would I want to hard code a path, even if I was including additional
functionality from another file?
> -----Original Message-----
> From: John W. Holmes [mailto:holmes072000@charter.net]
> Sent: Tuesday, February 10, 2004 1:50 PM
> To: Samuel Ventura; php-general@lists.php.net
> Subject: Re: [PHP] HELP: Nested include(...)'s take relative paths not
> intuitively
>
> From: "Samuel Ventura" <samuel_ventura@yahoo.com>
>
> > I have 3 files in nested subdirectories
> >
> > (1) /test.php
> > (2) /subdir1/test.php
> > (3) /subdir1/subdir2/test.php
> >
> > if I call (3) it loops forever in (2) trying to
> > including itself.
> >
> > Is this a bug or a feature?
>
> A feature?
>
> You make a request for (3). The thing to remember/realize is that now all
> require(), include(), etc. calls now happen relative to the path of (3).
> So,
> when you include (2), which tries to include ../test.php, it is trying to
> include itself again because the include() happens relative to the path of
> (3).
>
> include()'s are almost like a cut and paste. If you took the code from (2)
> and pasted it into (3) in place of the include(), that's the end result.
>
> This is why I do not use relative paths.
>
> ---John Holmes...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
******************************************************************
The contents of this e-mail and any files transmitted with it are
confidential and intended solely for the use of the individual or
entity to whom it is addressed. The views stated herein do not
necessarily represent the view of the company. If you are not the
intended recipient of this e-mail you may not copy, forward,
disclose, or otherwise use it or any part of it in any form
whatsoever. If you have received this e-mail in error please
e-mail the sender.
******************************************************************