Php 使用file_get_contents()指向现有插件文件夹的快捷路径是什么?

Php 使用file_get_contents()指向现有插件文件夹的快捷路径是什么?,php,wordpress,Php,Wordpress,我的代码在插件的init函数中,我试图在插件文件夹中的一个文件中归档_get_contents() 我在用 file_get_contents(ABSPATH.'/wp-content/plugins/myplugin/myfile.html'); 不知道为什么我不能用 file_get_contents('myfile.html'); myfile或myfile.html?尝试以下操作: file_get_contents('./myfile.html'); 您还可以使用文件功能来读取

我的代码在插件的init函数中,我试图在插件文件夹中的一个文件中归档_get_contents()

我在用

file_get_contents(ABSPATH.'/wp-content/plugins/myplugin/myfile.html');
不知道为什么我不能用

file_get_contents('myfile.html');

myfile
myfile.html?

尝试以下操作:

file_get_contents('./myfile.html');
您还可以使用文件功能来读取 特定文件

请参阅以下链接


您在php文件中调用file\u get\u内容是直接调用还是需要从另一个脚本调用? 从直接运行的文件计算的文件的路径。 例如:在index.php中,可能需要“plugins/i/stricn78.php”
如果在plugin78.php中调用file_get_contents('myfile.html'),那么myfile.html应该和index.php放在同一个类别中,而不是plugin78.php,我想是这样,但它仍然给我带来问题。我相信这是因为该文件是从另一个目录加载到plugins.php的,该目录将成为当前的相对路径?与其说是关于方法,不如说是关于在wordpress中插件的init函数中执行代码时路径的明显独特关系。