在php中包含目录

时间:2014-07-09 04:41:45

标签: php directory dir

如何在我的文件中包含目录??

我的文件夹就像这样

/require/connect_database.php
/ajax/anotherfolder/myfile.php

假设我在ajax文件夹(ajax/anotherfolder/myfile.php

上打开了我的一个文件

如何在/require中的myfile.php文件夹中添加文件?

我尝试过这样的事情,但它没有用。

** ** myfile.php

include '../require/connect_database.php';

1 个答案:

答案 0 :(得分:0)

你似乎错过了一个../。你有:

/ajax
    /anotherfolder
        /myfile.php
/require
    /connect_database.php

要从ajax/anotherfolder/myfile.php转到require/connect_database.php,您需要:

include '../../require/connect_database.php';