php include语句无法打开当前目录上方目录中的文件流

发布于 2024-12-22 13:46:09 字数 487 浏览 2 评论 0原文

我试图使用相对文件路径将文件包含在不同的目录中,但是我不断收到错误:

failed to open stream: No such file or directory

调用包含语句的文件的路径是

wp-content/plugins/php-code-widget/execphp.php

,我尝试包含的文件是

wp-content/uploads/espresso/templates/sidebar_widgets/register_widget.php

这是我的包含语句:

<?php include ('../../uploads/espresso/templates/sidebar_widgets/register_widget.php ?>

任何人看到问题了吗?

I am trying to include a file in a different directory using a relative file path however I keep getting the error:

failed to open stream: No such file or directory

The path of the file calling the include statement is

wp-content/plugins/php-code-widget/execphp.php

and the file I'm trying to include is

wp-content/uploads/espresso/templates/sidebar_widgets/register_widget.php

This is my include statement:

<?php include ('../../uploads/espresso/templates/sidebar_widgets/register_widget.php ?>

Anyone see the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫腻 2024-12-29 13:46:09

我会避免相对路径。

只要 WordPress 自从我上次使用以来没有发生太大变化,就可以尝试诸如...

include ABSPATH . 
     'wp-content/uploads/espresso/templates/sidebar_widgets/register_widget.php';

I would avoid the relative path.

So long as WordPress hasn't changed too much since I last used it, try something like...

include ABSPATH . 
     'wp-content/uploads/espresso/templates/sidebar_widgets/register_widget.php';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文