开发者

php includes chain

Here is my problem, I ve got an old w开发者_JAVA技巧ebsite which contains some modules like this,

root_dir
    |-->module1
    |-->module2
    |-->module3

For my need I add a sublevel to this structure, like this,

root_dir
    |-->module1
    |-->module2
        |-->submodule2.1
    |-->module3

My problem is that each module include an "include.php" file which then include other files, so if I fix the first path of the include.php to ../include.php it will crash at the second include file...

Is there a good workaround here, besides duplicating all the files and fix the path of the include ?

Thx


Have you tried using include_once for your common include.php file:

include_once('../include.php');

Or including the code once in a common ancestor file.

Or am I over simplifying? Are these options to you?


"there both standalone but they include the same include.php (which load the config environnment of the site)"

You better should have the configuration loaded already or work with some method (a factory to get configuration-data from, a global settings-class, …) that allows to load settings, without knowing anything about your actual file-structure (from a modules point of view). The same holds true for everything else you are using within the modules (like a database object).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜