包括根目录下子文件夹中的php文件

时间:2016-11-18 16:56:11

标签: php

我只是设置一个项目,我无法从子文件夹中使用我的标题。

从子文件夹/ mypage.php我想调用resources / includes / header-test.php。对我来说,这样做总是这样:

<?php include $_SERVER['DOCUMENT_ROOT'].'/resources/includes/header-test.php'; ?>

我无法解决这个问题,所以有人建议我如何做到这一点?

1 个答案:

答案 0 :(得分:2)

试试这个:

<?php include __DIR__.'/../resources/includes/header-test.php'; ?>