PHP require_once 在后面

PHP require_once in back

我的代码中有一个问题,我不知道如何解决。

我有这样的文件:

ROOT->INCLUDES - inc_files.php

和新文件

ROOT->INCLUDES->STRANICE - blog.class.php

如何在 blog.class.php 中使用 require_once 来包含 inc_files.php?

我的代码(blog.class.php)

require_once("./inc_files.php"); 

全部尝试

require_once("../inc_files.php"); 
require_once(".../inc_files.php"); 

还有更多... 请帮忙!

如何使用相对于当前 PHP 文件的路径?

在你的root/includes/stranice/blog.class.php中:

require_once(dirname(__DIR__) . "/inc_files.php");

您可以简单地使用

require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/inc_files.php');