2017-04-23 60 views
2

我有以下目錄結構:不能包含一個名爲我的PHP應用程序「的config.php」(它被忽略)文件

/app 
    /controlers 
    /models 
    /views 
    init.php 
    config.php 
/www 
    index.php 

/www/index.php代碼來調用init文件:

include_once '../app/init.php'; 
/app/init.php

然後,我有:

require_once 'config.php'; 
require_once 'routes.php'; 

由於某種原因,config.php文件未加載。如果我將它重命名爲config2.php並更改包含,那就很好。當我切換回原來的名字時,它會再次被忽略。有沒有機會以某種方式保留文件名?

我使用Apache與XAMPP一起提供。

回答

2

當你想包括來自相同目錄中的文件使用

require_once './config.php'; 
require_once './routes.php'; 

require_once __DIR__.'/config.php'; 
require_once __DIR__./'routes.php'; 

否則從您的include_path可能會包括,而不是...

同名的文件
相關問題