无法在我的 PHP 应用程序中包含名为 "config.php" 的文件(它被忽略)

Can't include a file named "config.php" in my PHP app (it gets ignored)

我有以下目录结构:

/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 并更改包含,一切都很好。但是,当我切换回原始名称时,它又被忽略了。文件名是否有可能以某种方式保留?

我正在使用 XAMPP 附带的 Apache。

当您想要包含同一目录中的文件时使用

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

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

否则可能会包含来自您 include_path 的同名文件...