更新时间:2022-06-15 23:13:44
你应该可以使用 __DIR__ 了.包含语句中的/data/functions.php"
(即前后两个下划线).
You should be able to use __DIR__ . "/data/functions.php"
in your include statement
(that's two underscores before and after).
我在我的测试环境中做了一个快速测试,没有任何问题.
I did a quick test in my test environment and had no problems.
__DIR__
魔术常量为您提供了正在运行的测试文件的完整路径.来自 PHP 网站:
The __DIR__
magic constant gives you the full path to the test file you are running. From the PHP website:
文件的目录.如果在包含内使用,则目录返回包含的文件.这相当于目录名(__FILE__)
.此目录名称没有尾部斜杠除非是根目录.
The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to
dirname(__FILE__)
. This directory name does not have a trailing slash unless it is the root directory.