【问题标题】:php include statement unable to open stream to file in directory above current directoryphp include 语句无法打开流到当前目录上方目录中的文件
【发布时间】:2011-12-22 06:18:00
【问题描述】:

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

failed to open stream: No such file or directory

调用include语句的文件路径是

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 ?>

有人发现问题了吗?

【问题讨论】:

    标签: php include relative-path filepath


    【解决方案1】:

    我会避开相对路径。

    只要 WordPress 自从我上次使用它以来没有太大变化,尝试类似...

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-21
      • 2015-11-13
      • 2016-08-03
      相关资源
      最近更新 更多