Re: HELP: Nested include(...)'s take relative paths not intuitively
| From: | John W. Holmes | Date: | Tue, 10 Feb 2004 19:50:14 +0000 |
| Subject: | Re: HELP: Nested include(...)'s take relative paths not intuitively | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177312@lists.php.net to get a copy of this message | ||
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...