problem of nesting includes...
| From: | Christian Dechery | Date: | Thu, 11 Oct 2001 02:15:59 +0000 |
| Subject: | problem of nesting includes... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-70753@lists.php.net to get a copy of this message | ||
We ran a serious thread about "nested includes()" and I saw a lot of pseudo-solutions...
and I've just implemented one of them which I think is the best... but while I was doing it I realised it is more 'pseudo' than I tought... it worked finally.... but this is what I've figured:
MAIN INCLUDE PROBLEM:
- if a file "a" includes "b" and "b" includes "c"... "c" won't have a path relative to "b"... so it won't work... (unless of course they are all in the same dir)
there's no 100% safe solution to work around nested includes with PHP... right?
there's no way you can assure in every file, that includes another and another (and so on) in different dirs... that it's allways safe and you won't run into the MAIN INCLUDE PROBLEM....
and if you want to change some dir you will ever have to go through every file and change something...
well... my pseudo-solution was:
if I had:
/vitrine
/vitrine/adm
/vitrine/include
/vitrine/templates
and in all these dirs I had files that can - or not - include files, and the includes also include more files... and so on... so I've placed a file called "include.conf.php" in /vitrine... and it should ALWAYS stay there (or at the bottom dir anyway)... so all I have to do is require() it in every single .php file I have...
this file defines something like INC_DIR that can be added to any call to include or require... and this INC_DIR is the actual DIR not www absolute or relative...
but I can only require("include.conf.php") on what I like to call TOP files... I mean... files that cannot be include()ed... or the whole thing won't work anymore... which for now is no problem... but I'm sure I'll have problems with this in the future...
_____________________________
. Christian Dechery
. . Gaita-L Owner / Web Developer
. . http://www.webstyle.com.br
. . http://www.tanamesa.com.br