PHP(wordpress):为什么我需要目录名(__FILE__)才能使用相对路径?

时间:2020-01-03 14:37:37

标签: php wordpress relative-path

如果我包含文件

include('test.php');

它可以工作,但是当我尝试使用相对路径将其包括在内

include('./test.php');

没有,因为如果我尝试包含父文件夹中的文件,也没有

include('../test.php');(一旦移动了文件)

我在Windows上,所以我进行了测试以防万一

include('.\test.php');

include('.\\test.php');

但是得到了相同的失败结果(无法打开流:没有这样的文件或目录)

*这是在wordpress插件中执行的


然后如果使用

include(dirname(__FILE__) . './test.php');

为什么?是什么原因?

0 个答案:

没有答案